本文整理汇总了Java中com.google.cloud.datastore.LongValue.newBuilder方法的典型用法代码示例。如果您正苦于以下问题:Java LongValue.newBuilder方法的具体用法?Java LongValue.newBuilder怎么用?Java LongValue.newBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.cloud.datastore.LongValue
的用法示例。
在下文中一共展示了LongValue.newBuilder方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toDatastore
import com.google.cloud.datastore.LongValue; //导入方法依赖的package包/类
@Override
public ValueBuilder<?, ?, ?> toDatastore(Object input) {
if (input == null) {
return NullValue.newBuilder();
}
return LongValue.newBuilder((int) input);
}
示例2: toDatastore
import com.google.cloud.datastore.LongValue; //导入方法依赖的package包/类
@Override
public ValueBuilder<?, ?, ?> toDatastore(Object input) {
if (input == null) {
return NullValue.newBuilder();
}
return LongValue.newBuilder((short) input);
}
示例3: toDatastore
import com.google.cloud.datastore.LongValue; //导入方法依赖的package包/类
@Override
public ValueBuilder<?, ?, ?> toDatastore(Object input) {
ValueBuilder<?, ?, ?> builder;
if (input == null) {
builder = NullValue.newBuilder();
} else if (input instanceof Long) {
builder = LongValue.newBuilder((long) input);
} else if (input instanceof Double) {
builder = DoubleValue.newBuilder((double) input);
} else if (input instanceof Boolean) {
builder = BooleanValue.newBuilder((boolean) input);
} else if (input instanceof String) {
builder = StringValue.newBuilder((String) input);
} else if (input instanceof DatastoreKey) {
builder = KeyValue.newBuilder(((DatastoreKey) input).nativeKey());
} else if (input instanceof GeoLocation) {
GeoLocation geoLocation = (GeoLocation) input;
builder = LatLngValue
.newBuilder(LatLng.of(geoLocation.getLatitude(), geoLocation.getLongitude()));
} else if (input instanceof Map) {
@SuppressWarnings("unchecked")
Map<String, ?> map = (Map<String, ?>) input;
FullEntity.Builder<IncompleteKey> entityBuilder = FullEntity.newBuilder();
for (Map.Entry<String, ?> entry : map.entrySet()) {
String key = entry.getKey();
entityBuilder.set(key, toDatastore(entry.getValue()).build());
}
builder = EntityValue.newBuilder(entityBuilder.build());
} else {
throw new MappingException(String.format("Unsupported type: %s", input.getClass().getName()));
}
return builder;
}
示例4: toDatastore
import com.google.cloud.datastore.LongValue; //导入方法依赖的package包/类
@Override
public ValueBuilder<?, ?, ?> toDatastore(Object input) {
if (input == null) {
return NullValue.newBuilder();
}
return LongValue.newBuilder((long) input);
}
示例5: toDatastore
import com.google.cloud.datastore.LongValue; //导入方法依赖的package包/类
@Override
public ValueBuilder<?, ?, ?> toDatastore(Object input) {
if (input == null) {
return NullValue.newBuilder();
}
return LongValue.newBuilder((byte) input);
}
示例6: toDatastore
import com.google.cloud.datastore.LongValue; //导入方法依赖的package包/类
@Override
public ValueBuilder<?, ?, ?> toDatastore(Object input) {
if (input == null) {
return NullValue.newBuilder();
}
try {
BigDecimal n = (BigDecimal) input;
n = n.movePointRight(fractionalDigits);
return LongValue.newBuilder(n.longValueExact());
} catch (Exception e) {
throw new MappingException(e);
}
}