Search in sources :

Example 6 with MapValue

use of com.google.firestore.v1.MapValue in project firebase-android-sdk by firebase.

the class ObjectValue method buildProto.

/**
 * Returns the Protobuf that backs this ObjectValue.
 *
 * <p>This method applies any outstanding modifications and memoizes the result. Further
 * invocations are based on this memoized result.
 */
private Value buildProto() {
    synchronized (overlayMap) {
        MapValue mergedResult = applyOverlay(FieldPath.EMPTY_PATH, overlayMap);
        if (mergedResult != null) {
            partialValue = Value.newBuilder().setMapValue(mergedResult).build();
            overlayMap.clear();
        }
    }
    return partialValue;
}
Also used : MapValue(com.google.firestore.v1.MapValue)

Example 7 with MapValue

use of com.google.firestore.v1.MapValue in project firebase-android-sdk by firebase.

the class FirestoreIndexValueWriter method writeIndexMap.

private void writeIndexMap(MapValue mapIndexValue, DirectionalIndexByteEncoder encoder) {
    writeValueTypeLabel(encoder, INDEX_TYPE_MAP);
    for (Map.Entry<String, Value> entry : mapIndexValue.getFieldsMap().entrySet()) {
        String key = entry.getKey();
        Value value = entry.getValue();
        writeIndexString(key, encoder);
        writeIndexValueAux(value, encoder);
    }
}
Also used : Value(com.google.firestore.v1.Value) ArrayValue(com.google.firestore.v1.ArrayValue) MapValue(com.google.firestore.v1.MapValue) Map(java.util.Map)

Example 8 with MapValue

use of com.google.firestore.v1.MapValue in project firebase-android-sdk by firebase.

the class BundleSerializerTest method testDecodesNestedObjectValues.

@Test
public void testDecodesNestedObjectValues() throws JSONException {
    String json = "{ mapValue: { fields: {\n" + "b: { booleanValue: true },\n" + "d: {\n" + "    doubleValue:\n" + Double.MAX_VALUE + "},\n" + "i: { integerValue: 1 },\n" + "n: { nullValue: null },\n" + "s: { stringValue: 'foo' },\n" + "a: { arrayValue: {\n" + "    values: [\n" + "      { integerValue: 2 },\n" + "      { stringValue: 'bar'},\n" + "      { mapValue: { fields: { b: { booleanValue: false } } } }\n" + "    ]\n" + "  }\n" + "},\n" + "o: {\n" + "  mapValue: {\n" + "    fields: {\n" + "      d: { integerValue: 100 },\n" + "      nested: {\n" + "         mapValue: {\n" + "           fields: {\n" + "             e: { integerValue:\n" + Long.MIN_VALUE + "            }\n" + "          }\n" + "        }\n" + "      }\n" + "    }\n" + "  }\n" + "} } } }\n";
    MapValue.Builder inner = MapValue.newBuilder().putFields("b", Value.newBuilder().setBooleanValue(false).build());
    ArrayValue.Builder array = ArrayValue.newBuilder().addValues(Value.newBuilder().setIntegerValue(2)).addValues(Value.newBuilder().setStringValue("bar")).addValues(Value.newBuilder().setMapValue(inner));
    inner = MapValue.newBuilder().putFields("e", Value.newBuilder().setIntegerValue(Long.MIN_VALUE).build());
    MapValue.Builder middle = MapValue.newBuilder().putFields("d", Value.newBuilder().setIntegerValue(100).build()).putFields("nested", Value.newBuilder().setMapValue(inner).build());
    MapValue.Builder obj = MapValue.newBuilder().putFields("b", Value.newBuilder().setBooleanValue(true).build()).putFields("d", Value.newBuilder().setDoubleValue(Double.MAX_VALUE).build()).putFields("i", Value.newBuilder().setIntegerValue(1).build()).putFields("n", Value.newBuilder().setNullValueValue(0).build()).putFields("s", Value.newBuilder().setStringValue("foo").build()).putFields("a", Value.newBuilder().setArrayValue(array).build()).putFields("o", Value.newBuilder().setMapValue(middle).build());
    Value proto = Value.newBuilder().setMapValue(obj).build();
    assertDecodesValue(json, proto);
}
Also used : ObjectValue(com.google.firebase.firestore.model.ObjectValue) Value(com.google.firestore.v1.Value) NullValue(com.google.protobuf.NullValue) MapValue(com.google.firestore.v1.MapValue) ArrayValue(com.google.firestore.v1.ArrayValue) MapValue(com.google.firestore.v1.MapValue) ArrayValue(com.google.firestore.v1.ArrayValue) Test(org.junit.Test)

Aggregations

MapValue (com.google.firestore.v1.MapValue)6 Value (com.google.firestore.v1.Value)5 Map (java.util.Map)5 ArrayValue (com.google.firestore.v1.ArrayValue)3 HashMap (java.util.HashMap)3 ExprValue (com.google.api.expr.v1alpha1.ExprValue)2 ListValue (com.google.api.expr.v1alpha1.ListValue)2 MapValue (com.google.api.expr.v1alpha1.MapValue)2 Value (com.google.api.expr.v1alpha1.Value)2 ByteString (com.google.protobuf.ByteString)2 Duration (com.google.protobuf.Duration)2 Message (com.google.protobuf.Message)2 NullValue (com.google.protobuf.NullValue)2 Timestamp (com.google.protobuf.Timestamp)2 IteratorT (org.projectnessie.cel.common.types.IteratorT)2 TypeT (org.projectnessie.cel.common.types.TypeT)2 TypeT.newObjectTypeValue (org.projectnessie.cel.common.types.TypeT.newObjectTypeValue)2 Val (org.projectnessie.cel.common.types.ref.Val)2 Lister (org.projectnessie.cel.common.types.traits.Lister)2 Mapper (org.projectnessie.cel.common.types.traits.Mapper)2