@Override protected FullEntity<?> getValue(com.google.datastore.v1.Value from) { return FullEntity.fromPb(from.getEntityValue()); }
case 6: hash = (37 * hash) + ENTITY_VALUE_FIELD_NUMBER; hash = (53 * hash) + getEntityValue().hashCode(); break; case 9:
break; case 6: result = result && getEntityValue().equals(other.getEntityValue()); break; case 9:
mergeEntityValue(other.getEntityValue()); break;
static class EmbeddedStringExtractor extends DoFn<Entity, String> { @Override public void processElement(ProcessContext c) { Map<String, Value> main_entity_map = DatastoreHelper.getPropertyMap(c.element()); List<Value> embedded_entity_values = entity.get("embedded_entity").getListValueList(); for (Value embedded_entity_value: embedded_entity_values){ Entity embedded_entity = embedded_entity_value.getEntityValue(); Map<String, Value> embedded_map = DatastoreHelper.getPropertyMap(embedded_entity); String embedded_name = DatastoreHelper.getString(embedded_map.get("name")); } // And then just c.output whatever you need. } }
/** * @return the entity contained in value * @throws IllegalArgumentException if the value does not contain an entity. */ public static Entity getEntity(Value value) { if (value.getValueTypeCase() != ValueTypeCase.ENTITY_VALUE) { throw new IllegalArgumentException("Value does not contain an Entity."); } return value.getEntityValue(); }
/** * @return the entity contained in value * @throws IllegalArgumentException if the value does not contain an entity. */ public static Entity getEntity(Value value) { if (value.getValueTypeCase() != ValueTypeCase.ENTITY_VALUE) { throw new IllegalArgumentException("Value does not contain an Entity."); } return value.getEntityValue(); }
@Override protected FullEntity<?> getValue(com.google.datastore.v1.Value from) { return FullEntity.fromPb(from.getEntityValue()); }
/** * Return the value as an {@code Entity}. * * @return the value. * @throws IllegalArgumentException if {@code Value} is not an entity. */ public Entity getEntity() { if (!isEntity()) { throw new IllegalArgumentException("Value does not contain an entity."); } return Entity.builder(value.getEntityValue()).build(); }
/** * Grabs the schema for what data is in the Array. * @param arrayValue a populated array * @return a schema of what kind of data is in the array */ private JsonArray arraySchema(ArrayValue arrayValue) { Set<JsonObject> entities = new HashSet<>(); Set<String> primitives = new HashSet<>(); Set<JsonArray> subArrays = new HashSet<>(); arrayValue.getValuesList().stream().forEach(value -> { switch (value.getValueTypeCase()) { case ENTITY_VALUE: entities.add(entitySchema(value.getEntityValue())); break; case ARRAY_VALUE: subArrays.add(arraySchema(value.getArrayValue())); break; default: primitives.add(value.getValueTypeCase().toString()); break; } }); JsonArray jsonArray = new JsonArray(); entities.stream().forEach(jsonArray::add); primitives.stream().forEach(jsonArray::add); subArrays.stream().forEach(jsonArray::add); return jsonArray; }
/** * Grabs the schema for what data is in the Entity. * @param entity a populated entity * @return a schema of what kind of data is in the entity */ private JsonObject entitySchema(Entity entity) { JsonObject jsonObject = new JsonObject(); entity.getPropertiesMap().entrySet().stream().forEach(entrySet -> { String key = entrySet.getKey(); Value value = entrySet.getValue(); switch (value.getValueTypeCase()) { case ENTITY_VALUE: jsonObject.add(key, entitySchema(value.getEntityValue())); break; case ARRAY_VALUE: jsonObject.add(key, arraySchema(value.getArrayValue())); break; default: jsonObject.addProperty(key, value.getValueTypeCase().toString()); } }); return jsonObject; }
case 6: hash = (37 * hash) + ENTITY_VALUE_FIELD_NUMBER; hash = (53 * hash) + getEntityValue().hashCode(); break; case 9:
case 6: hash = (37 * hash) + ENTITY_VALUE_FIELD_NUMBER; hash = (53 * hash) + getEntityValue().hashCode(); break; case 9:
break; case 6: result = result && getEntityValue().equals(other.getEntityValue()); break; case 9:
break; case 6: result = result && getEntityValue() .equals(other.getEntityValue()); break; case 9:
mergeEntityValue(other.getEntityValue()); break;
mergeEntityValue(other.getEntityValue()); break;