com.google.cloud.datastore.Entity.getEntity()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(93)

本文整理了Java中com.google.cloud.datastore.Entity.getEntity()方法的一些代码示例,展示了Entity.getEntity()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getEntity()方法的具体详情如下:
包路径:com.google.cloud.datastore.Entity
类名称:Entity
方法名:getEntity

Entity.getEntity介绍

暂无

代码示例

代码示例来源:origin: googleapis/google-cloud-java

FullEntity<IncompleteKey> contact = user.getEntity("contact");
String email = contact.getString("email");
String phone = contact.getString("phone");

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testGetArrayNoDeferredResults() {
 DATASTORE.put(ENTITY3);
 Iterator<Entity> result =
   DATASTORE.fetch(KEY1, Key.newBuilder(KEY1).setName("bla").build(), KEY2, KEY3).iterator();
 assertEquals(ENTITY1, result.next());
 assertNull(result.next());
 assertEquals(ENTITY2, result.next());
 Entity entity3 = result.next();
 assertEquals(ENTITY3, entity3);
 assertTrue(entity3.isNull("null"));
 assertFalse(entity3.getBoolean("bool"));
 assertEquals(LIST_VALUE2.get(), entity3.getList("list"));
 FullEntity<IncompleteKey> partial1 = entity3.getEntity("partial1");
 FullEntity<IncompleteKey> partial2 = entity3.getEntity("partial2");
 assertEquals(PARTIAL_ENTITY2, partial1);
 assertEquals(ENTITY2, partial2);
 assertEquals(ValueType.BOOLEAN, entity3.getValue("bool").getType());
 assertEquals(LAT_LNG_VALUE, entity3.getValue("latLng"));
 assertEquals(EMPTY_LIST_VALUE, entity3.getValue("emptyList"));
 assertEquals(8, entity3.getNames().size());
 assertFalse(entity3.contains("bla"));
 try {
  entity3.getString("str");
  fail("Expecting a failure");
 } catch (DatastoreException expected) {
  // expected - no such property
 }
 assertFalse(result.hasNext());
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testGetArrayNoDeferredResults() {
 datastore.put(ENTITY3);
 Iterator<Entity> result =
   datastore.fetch(KEY1, Key.newBuilder(KEY1).setName("bla").build(), KEY2, KEY3).iterator();
 assertEquals(ENTITY1, result.next());
 assertNull(result.next());
 assertEquals(ENTITY2, result.next());
 Entity entity3 = result.next();
 assertEquals(ENTITY3, entity3);
 assertTrue(entity3.isNull("null"));
 assertFalse(entity3.getBoolean("bool"));
 assertEquals(LIST_VALUE2.get(), entity3.getList("list"));
 FullEntity<IncompleteKey> partial1 = entity3.getEntity("partial1");
 FullEntity<IncompleteKey> partial2 = entity3.getEntity("partial2");
 assertEquals(PARTIAL_ENTITY2, partial1);
 assertEquals(ENTITY2, partial2);
 assertEquals(ValueType.BOOLEAN, entity3.getValue("bool").getType());
 assertEquals(LAT_LNG_VALUE, entity3.getValue("latLng"));
 assertEquals(EMPTY_LIST_VALUE, entity3.getValue("emptyList"));
 assertEquals(8, entity3.getNames().size());
 assertFalse(entity3.contains("bla"));
 try {
  entity3.getString("str");
  fail("Expecting a failure");
 } catch (DatastoreException expected) {
  // expected - no such property
 }
 assertFalse(result.hasNext());
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testGet() {
 Entity entity = datastore.get(KEY3);
 assertNull(entity);
 entity = datastore.get(KEY1);
 assertEquals(ENTITY1, entity);
 StringValue value1 = entity.getValue("str");
 assertEquals(STR_VALUE, value1);
 BooleanValue value2 = entity.getValue("bool");
 assertEquals(BOOL_VALUE, value2);
 ListValue value3 = entity.getValue("list");
 assertEquals(LIST_VALUE2, value3);
 TimestampValue value4 = entity.getValue("date");
 assertEquals(TIMESTAMP_VALUE, value4);
 LatLngValue value5 = entity.getValue("latLng");
 assertEquals(LAT_LNG_VALUE, value5);
 FullEntity<IncompleteKey> value6 = entity.getEntity("partial1");
 assertEquals(PARTIAL_ENTITY1, value6);
 ListValue value7 = entity.getValue("emptyList");
 assertEquals(EMPTY_LIST_VALUE, value7);
 assertEquals(7, entity.getNames().size());
 assertFalse(entity.contains("bla"));
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testGet() {
 Entity entity = DATASTORE.get(KEY3);
 assertNull(entity);
 entity = DATASTORE.get(KEY1);
 assertEquals(ENTITY1, entity);
 StringValue value1 = entity.getValue("str");
 assertEquals(STR_VALUE, value1);
 BooleanValue value2 = entity.getValue("bool");
 assertEquals(BOOL_VALUE, value2);
 ListValue value3 = entity.getValue("list");
 assertEquals(LIST_VALUE2, value3);
 TimestampValue value4 = entity.getValue("date");
 assertEquals(TIMESTAMP_VALUE, value4);
 LatLngValue value5 = entity.getValue("latLng");
 assertEquals(LAT_LNG_VALUE, value5);
 FullEntity<IncompleteKey> value6 = entity.getEntity("partial1");
 assertEquals(PARTIAL_ENTITY1, value6);
 ListValue value7 = entity.getValue("emptyList");
 assertEquals(EMPTY_LIST_VALUE, value7);
 assertEquals(7, entity.getNames().size());
 assertFalse(entity.contains("bla"));
}

相关文章