本文整理汇总了Java中com.google.cloud.datastore.FullEntity.getNames方法的典型用法代码示例。如果您正苦于以下问题:Java FullEntity.getNames方法的具体用法?Java FullEntity.getNames怎么用?Java FullEntity.getNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.cloud.datastore.FullEntity
的用法示例。
在下文中一共展示了FullEntity.getNames方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toModel
import com.google.cloud.datastore.FullEntity; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object toModel(Value<?> input) {
if (input instanceof NullValue) {
return null;
}
EntityValue entityValue = (EntityValue) input;
FullEntity<?> entity = entityValue.get();
Map<String, Object> map;
if (Modifier.isAbstract(mapClass.getModifiers())) {
if (SortedMap.class.equals(mapClass)) {
map = new TreeMap<>();
} else {
map = new HashMap<>();
}
} else {
map = (Map<String, Object>) IntrospectionUtils.instantiateObject(mapClass);
}
for (String property : entity.getNames()) {
map.put(property, valueMapper.toModel(entity.getValue(property)));
}
return map;
}
示例2: unmarshalToMap
import com.google.cloud.datastore.FullEntity; //导入方法依赖的package包/类
public <K extends IncompleteKey> void unmarshalToMap(FullEntity<K> entity,
Map<String, Object> map) {
for (String name : entity.getNames()) {
Value<?> value = entity.getValue(name);
ValueType valueType = value.getType();
switch (valueType) {
case ENTITY:
if (map.containsKey(name)) {
unmarshalToObject(entity.getEntity(name), map.get(name));
}
else {
Map<String, Object> newMap = new HashMap<>();
unmarshalToMap(entity.getEntity(name), newMap);
map.put(name, newMap);
}
break;
case BLOB:
case BOOLEAN:
case DOUBLE:
case LAT_LNG:
case LIST:
case LONG:
case NULL:
case STRING:
case TIMESTAMP:
map.put(name, unmarshal(value));
break;
case KEY:
break;
case RAW_VALUE:
throw new UnsupportedOperationException(valueType.toString());
}
}
}
示例3: toModel
import com.google.cloud.datastore.FullEntity; //导入方法依赖的package包/类
@Override
public Object toModel(Value<?> input) {
Object javaValue;
if (input instanceof NullValue) {
javaValue = null;
} else if (input instanceof StringValue) {
javaValue = input.get();
} else if (input instanceof LongValue) {
javaValue = input.get();
} else if (input instanceof DoubleValue) {
javaValue = input.get();
} else if (input instanceof BooleanValue) {
javaValue = input.get();
} else if (input instanceof KeyValue) {
javaValue = new DefaultDatastoreKey(((KeyValue) input).get());
} else if (input instanceof LatLngValue) {
LatLng latLong = ((LatLngValue) input).get();
javaValue = new GeoLocation(latLong.getLatitude(), latLong.getLongitude());
} else if (input instanceof EntityValue) {
EntityValue entityValue = (EntityValue) input;
FullEntity<?> entity = entityValue.get();
Map<String, Object> map = new HashMap<>();
for (String property : entity.getNames()) {
map.put(property, toModel(entity.getValue(property)));
}
javaValue = map;
} else {
throw new MappingException(String.format("Unsupported type %s", input.getClass().getName()));
}
return javaValue;
}
示例4: valueOf
import com.google.cloud.datastore.FullEntity; //导入方法依赖的package包/类
private Object valueOf(Value<?> value) {
switch (value.getType()) {
case NULL:
return null;
case STRING:
return ((StringValue) value).get();
case ENTITY:
Map<String, Object> map2 = new HashMap<>();
FullEntity<?> fe = ((EntityValue) value).get();
Set<String> names = fe.getNames();
for (String nom : names) {
GoogleDatastoreKeyStore.put(map2, nom, fe.getValue(nom));
}
return map2;
case LIST:
List<? extends Value<?>> list = ((ListValue) value).get();
List<String> slist = new ArrayList<>();
// TODO this may be an oversimplification
for (Value<?> v : list) {
if (v instanceof StringValue) slist.add(((StringValue) v).get());
}
return slist;
case KEY:
return((KeyValue) value).get();
case LONG:
return((LongValue) value).get();
case DOUBLE:
return((DoubleValue) value).get();
case BOOLEAN:
return ((BooleanValue) value).get();
case BLOB:
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
IOUtils.copy(((BlobValue) value).get().asInputStream(), baos);
return(baos.toString());
} catch (IOException e) {
log.error("Cannot read blob: " + e.getMessage());
break;
}
case RAW_VALUE:
return((RawValue) value).get();
case LAT_LNG:
return((LatLngValue) value).get();
default:
throw new RuntimeException("Can't yet");
}
return null;
}
示例5: put
import com.google.cloud.datastore.FullEntity; //导入方法依赖的package包/类
public static void put(Map<String, Object> map, String name, Value<?> value) {
switch (value.getType()) {
case STRING:
map.put(name, ((StringValue) value).get());
break;
case NULL:
map.put(name, null);
break;
case ENTITY:
Map<String, Object> map2 = new HashMap<>();
FullEntity<?> fe = ((EntityValue) value).get();
Set<String> names = fe.getNames();
for (String nom : names) {
put(map2, nom, fe.getValue(nom));
}
map.put(name, map2);
break;
case LIST:
List<? extends Value<?>> list = ((ListValue) value).get();
List<String> slist = new ArrayList<>();
// TODO this may be an oversimplification
for (Value<?> v : list) {
if (v instanceof StringValue) slist.add(((StringValue) v).get());
}
map.put(name, slist);
break;
case KEY:
map.put(name, ((KeyValue) value).get());
break;
case LONG:
map.put(name, ((LongValue) value).get());
break;
case DOUBLE:
map.put(name, ((DoubleValue) value).get());
break;
case BOOLEAN:
map.put(name, ((BooleanValue) value).get());
break;
case BLOB:
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
IOUtils.copy(((BlobValue) value).get().asInputStream(), baos);
map.put(name, baos.toString());
} catch (IOException e) {
log.error("Cannot read blob: " + e.getMessage());
}
break;
case RAW_VALUE:
map.put(name, ((RawValue) value).get());
break;
case LAT_LNG:
map.put(name, ((LatLngValue) value).get());
break;
default:
throw new RuntimeException("Can't yet");
}
}