@Override protected List<Value<?>> getValue(com.google.datastore.v1.Value from) { List<Value<?>> properties = new ArrayList<>(from.getArrayValue().getValuesCount()); for (com.google.datastore.v1.Value valuePb : from.getArrayValue().getValuesList()) { properties.add(Value.fromPb(valuePb)); } return properties; }
case 9: hash = (37 * hash) + ARRAY_VALUE_FIELD_NUMBER; hash = (53 * hash) + getArrayValue().hashCode(); break; case 0:
break; case 9: result = result && getArrayValue().equals(other.getArrayValue()); break; case 0:
mergeArrayValue(other.getArrayValue()); break;
/** * Return the value as a list of {@code Value}. * * @return the list value, an empty list indicates that the value is not set. */ public List<Value> getList() { return ImmutableList.copyOf( value.getArrayValue().getValuesList().stream().map(Value::new).iterator()); }
@Override protected List<Value<?>> getValue(com.google.datastore.v1.Value from) { List<Value<?>> properties = new ArrayList<>(from.getArrayValue().getValuesCount()); for (com.google.datastore.v1.Value valuePb : from.getArrayValue().getValuesList()) { properties.add(Value.fromPb(valuePb)); } return properties; }
/** * @return the array contained in value as a list. * @throws IllegalArgumentException if the value does not contain an array. */ public static List<Value> getList(Value value) { if (value.getValueTypeCase() != ValueTypeCase.ARRAY_VALUE) { throw new IllegalArgumentException("Value does not contain an array."); } return value.getArrayValue().getValuesList(); }
/** * @return the array contained in value as a list. * @throws IllegalArgumentException if the value does not contain an array. */ public static List<Value> getList(Value value) { if (value.getValueTypeCase() != ValueTypeCase.ARRAY_VALUE) { throw new IllegalArgumentException("Value does not contain an array."); } return value.getArrayValue().getValuesList(); }
/** * 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 9: hash = (37 * hash) + ARRAY_VALUE_FIELD_NUMBER; hash = (53 * hash) + getArrayValue().hashCode(); break; case 0:
case 9: hash = (37 * hash) + ARRAY_VALUE_FIELD_NUMBER; hash = (53 * hash) + getArrayValue().hashCode(); break; case 0:
break; case 9: result = result && getArrayValue().equals(other.getArrayValue()); break; case 0:
break; case 9: result = result && getArrayValue() .equals(other.getArrayValue()); break; case 0:
mergeArrayValue(other.getArrayValue()); break;
mergeArrayValue(other.getArrayValue()); break;