use of com.google.api.expr.v1alpha1.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;
}
use of com.google.api.expr.v1alpha1.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);
}
}
use of com.google.api.expr.v1alpha1.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);
}
Aggregations