@Test public void testConvertsTimestampValue() { List<Timestamp> testCases = asList(new Timestamp(0, 0), new Timestamp(1356048000L, 0)); for (Timestamp t : testCases) { Value value = wrap(t); assertValueType(Value.ValueTypeCase.TIMESTAMP_VALUE, value); Object convertedValue = convertValue(value); assertEquals(t, convertedValue); } }
Object convertValue(Value value) { switch (typeOrder(value)) { case TYPE_ORDER_MAP: return convertObject(value.getMapValue().getFieldsMap()); case TYPE_ORDER_ARRAY: return convertArray(value.getArrayValue()); case TYPE_ORDER_REFERENCE: return convertReference(value); case TYPE_ORDER_TIMESTAMP: return convertTimestamp(value.getTimestampValue()); case TYPE_ORDER_SERVER_TIMESTAMP: return convertServerTimestamp(value); case TYPE_ORDER_NULL: return null; case TYPE_ORDER_BOOLEAN: return value.getBooleanValue(); case TYPE_ORDER_NUMBER: return value.getValueTypeCase().equals(Value.ValueTypeCase.INTEGER_VALUE) ? (Object) value.getIntegerValue() : (Object) value.getDoubleValue(); case TYPE_ORDER_STRING: return value.getStringValue(); case TYPE_ORDER_BLOB: return Blob.fromByteString(value.getBytesValue()); case TYPE_ORDER_GEOPOINT: return new GeoPoint( value.getGeoPointValue().getLatitude(), value.getGeoPointValue().getLongitude()); default: throw fail("Unknown value type: " + value.getValueTypeCase()); } }
UserDataWriter { Object convertValue(Value value) { switch (typeOrder(value)) { case TYPE_ORDER_MAP: return convertObject(value.getMapValue().getFieldsMap()); case TYPE_ORDER_ARRAY: return convertArray(value.getArrayValue()); case TYPE_ORDER_REFERENCE: return convertReference(value); case TYPE_ORDER_TIMESTAMP: return convertTimestamp(value.getTimestampValue()); case TYPE_ORDER_SERVER_TIMESTAMP: return convertServerTimestamp(value); case TYPE_ORDER_NULL: return null; case TYPE_ORDER_BOOLEAN: return value.getBooleanValue(); case TYPE_ORDER_NUMBER: return value.getValueTypeCase().equals(Value.ValueTypeCase.INTEGER_VALUE) ? (Object) value.getIntegerValue() : (Object) value.getDoubleValue(); case TYPE_ORDER_STRING: return value.getStringValue(); case TYPE_ORDER_BLOB: return Blob.fromByteString(value.getBytesValue()); case TYPE_ORDER_GEOPOINT: return new GeoPoint( value.getGeoPointValue().getLatitude(), value.getGeoPointValue().getLongitude()); default: throw fail("Unknown value type: " + value.getValueTypeCase()); } } }
UserDataWriter { Object convertValue(Value value) { switch (typeOrder(value)) { case TYPE_ORDER_MAP: return convertObject(value.getMapValue().getFieldsMap()); case TYPE_ORDER_ARRAY: return convertArray(value.getArrayValue()); case TYPE_ORDER_REFERENCE: return convertReference(value); case TYPE_ORDER_TIMESTAMP: return convertTimestamp(value.getTimestampValue()); case TYPE_ORDER_SERVER_TIMESTAMP: return convertServerTimestamp(value); case TYPE_ORDER_NULL: return null; case TYPE_ORDER_BOOLEAN: return value.getBooleanValue(); case TYPE_ORDER_NUMBER: return value.getValueTypeCase().equals(Value.ValueTypeCase.INTEGER_VALUE) ? (Object) value.getIntegerValue() : (Object) value.getDoubleValue(); case TYPE_ORDER_STRING: return value.getStringValue(); case TYPE_ORDER_BLOB: return Blob.fromByteString(value.getBytesValue()); case TYPE_ORDER_GEOPOINT: return new GeoPoint( value.getGeoPointValue().getLatitude(), value.getGeoPointValue().getLongitude()); default: throw fail("Unknown value type: " + value.getValueTypeCase()); } } UserDataWriter(
      FirebaseFirestore firestore,
      boolean timestampsInSnapshots,
      DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior); }
UserDataWriter { Object convertValue(Value value) { switch (typeOrder(value)) { case TYPE_ORDER_MAP: return convertObject(value.getMapValue().getFieldsMap()); case TYPE_ORDER_ARRAY: return convertArray(value.getArrayValue()); case TYPE_ORDER_REFERENCE: return convertReference(value); case TYPE_ORDER_TIMESTAMP: return convertTimestamp(value.getTimestampValue()); case TYPE_ORDER_SERVER_TIMESTAMP: return convertServerTimestamp(value); case TYPE_ORDER_NULL: return null; case TYPE_ORDER_BOOLEAN: return value.getBooleanValue(); case TYPE_ORDER_NUMBER: return value.getValueTypeCase().equals(Value.ValueTypeCase.INTEGER_VALUE) ? (Object) value.getIntegerValue() : (Object) value.getDoubleValue(); case TYPE_ORDER_STRING: return value.getStringValue(); case TYPE_ORDER_BLOB: return Blob.fromByteString(value.getBytesValue()); case TYPE_ORDER_GEOPOINT: return new GeoPoint( value.getGeoPointValue().getLatitude(), value.getGeoPointValue().getLongitude()); default: throw fail("Unknown value type: " + value.getValueTypeCase()); } } UserDataWriter(
      FirebaseFirestore firestore,
      boolean timestampsInSnapshots,
      DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior);  }
UserDataWriter { Object convertValue(Value value) { switch (typeOrder(value)) { case TYPE_ORDER_MAP: return convertObject(value.getMapValue().getFieldsMap()); case TYPE_ORDER_ARRAY: return convertArray(value.getArrayValue()); case TYPE_ORDER_REFERENCE: return convertReference(value); case TYPE_ORDER_TIMESTAMP: return convertTimestamp(value.getTimestampValue()); case TYPE_ORDER_SERVER_TIMESTAMP: return convertServerTimestamp(value); case TYPE_ORDER_NULL: return null; case TYPE_ORDER_BOOLEAN: return value.getBooleanValue(); case TYPE_ORDER_NUMBER: return value.getValueTypeCase().equals(Value.ValueTypeCase.INTEGER_VALUE) ? (Object) value.getIntegerValue() : (Object) value.getDoubleValue(); case TYPE_ORDER_STRING: return value.getStringValue(); case TYPE_ORDER_BLOB: return Blob.fromByteString(value.getBytesValue()); case TYPE_ORDER_GEOPOINT: return new GeoPoint( value.getGeoPointValue().getLatitude(), value.getGeoPointValue().getLongitude()); default: throw fail("Unknown value type: " + value.getValueTypeCase()); } } UserDataWriter(
      FirebaseFirestore firestore,
      boolean timestampsInSnapshots,
      DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior);   }