本文整理了Java中com.google.cloud.datastore.Entity.getDouble()
方法的一些代码示例,展示了Entity.getDouble()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getDouble()
方法的具体详情如下:
包路径:com.google.cloud.datastore.Entity
类名称:Entity
方法名:getDouble
暂无
代码示例来源:origin: google/data-transfer-project
private static Map<String, Object> getProperties(Entity entity)
throws IOException, ClassNotFoundException {
if (entity == null) {
return null;
}
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
for (String property : entity.getNames()) {
// builder.put(property, entity.getValue(property));
if (entity.getValue(property) instanceof StringValue) {
builder.put(property, (String) entity.getString(property));
} else if (entity.getValue(property) instanceof LongValue) {
// This conversion is safe because of integer to long conversion above
builder.put(property, new Long(entity.getLong(property)).intValue());
} else if (entity.getValue(property) instanceof DoubleValue) {
builder.put(property, (Double) entity.getDouble(property));
} else if (entity.getValue(property) instanceof BooleanValue) {
builder.put(property, (Boolean) entity.getBoolean(property));
} else if (entity.getValue(property) instanceof TimestampValue) {
builder.put(property, (Timestamp) entity.getTimestamp(property));
} else {
Blob blob = entity.getBlob(property);
Object obj = null;
try (ObjectInputStream in = new ObjectInputStream(blob.asInputStream())) {
obj = in.readObject();
}
builder.put(property, obj); // BlobValue
}
}
return builder.build();
}
代码示例来源:origin: spotify/styx
static RunState entityToRunState(Entity entity, WorkflowInstance instance)
throws IOException {
final long counter = entity.getLong(PROPERTY_COUNTER);
final State state = State.valueOf(entity.getString(PROPERTY_STATE));
final long timestamp = entity.getLong(PROPERTY_STATE_TIMESTAMP);
final StateData data = StateData.newBuilder()
.tries((int) entity.getLong(PROPERTY_STATE_TRIES))
.consecutiveFailures((int) entity.getLong(PROPERTY_STATE_CONSECUTIVE_FAILURES))
.retryCost(entity.getDouble(PROPERTY_STATE_RETRY_COST))
.trigger(DatastoreStorage.<String>readOpt(entity, PROPERTY_STATE_TRIGGER_TYPE).map(type ->
TriggerUtil.trigger(type, entity.getString(PROPERTY_STATE_TRIGGER_ID))))
.messages(OBJECT_MAPPER.<List<Message>>readValue(entity.getString(PROPERTY_STATE_MESSAGES),
new TypeReference<List<Message>>() { }))
.retryDelayMillis(readOpt(entity, PROPERTY_STATE_RETRY_DELAY_MILLIS))
.lastExit(DatastoreStorage.<Long>readOpt(entity, PROPERTY_STATE_LAST_EXIT).map(Long::intValue))
.executionId(readOpt(entity, PROPERTY_STATE_EXECUTION_ID))
.executionDescription(readOptJson(entity, PROPERTY_STATE_EXECUTION_DESCRIPTION,
ExecutionDescription.class))
.resourceIds(readOptJson(entity, PROPERTY_STATE_RESOURCE_IDS,
new TypeReference<Set<String>>() { }))
.triggerParameters(readOptJson(entity, PROPERTY_STATE_TRIGGER_PARAMETERS, TriggerParameters.class))
.build();
return RunState.create(instance, state, data, Instant.ofEpochMilli(timestamp), counter);
}
内容来源于网络,如有侵权,请联系作者删除!