@SuppressWarnings("UnnecessaryBoxing") @Test public void testConvertsDoubleValue() { List<Double> testCases = asList( Double.POSITIVE_INFINITY, -Double.MAX_VALUE, Double.valueOf(-Float.MAX_VALUE), Long.MIN_VALUE * 1.0, -1.1, Double.valueOf(-Float.MIN_VALUE), -Double.MIN_VALUE, -0.0, 0.0, Double.valueOf(Float.MIN_VALUE), Double.MIN_VALUE, Double.valueOf(Float.MIN_NORMAL), Double.MIN_NORMAL, Long.MAX_VALUE * 1.0, Double.valueOf(Float.MAX_VALUE), Double.MAX_VALUE, Double.POSITIVE_INFINITY, Double.NaN); for (Double d : testCases) { Value value = wrap(d); assertValueType(Value.ValueTypeCase.DOUBLE_VALUE, value); Object convertedValue = convertValue(value); assertEquals(d, 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);   }