@JsonCreator public static TypedValue create(@JsonProperty("type") String type, @JsonProperty("value") Object value) { if (value == null) { return EXPLICIT_NULL; } ColumnMetaData.Rep rep = ColumnMetaData.Rep.valueOf(type); return ofLocal(rep, serialToLocal(rep, value)); }
@JsonCreator public static TypedValue create(@JsonProperty("type") String type, @JsonProperty("value") Object value) { if (value == null) { return NULL; } ColumnMetaData.Rep rep = ColumnMetaData.Rep.valueOf(type); return ofLocal(rep, serialToLocal(rep, value)); }
@JsonCreator public static TypedValue create(@JsonProperty("type") String type, @JsonProperty("value") Object value) { if (value == null) { return EXPLICIT_NULL; } ColumnMetaData.Rep rep = ColumnMetaData.Rep.valueOf(type); return ofLocal(rep, serialToLocal(rep, value)); }
@Test public void testUtilDate() { serializeAndEqualityCheck( TypedValue.ofLocal(Rep.JAVA_UTIL_DATE, System.currentTimeMillis())); }
@Test public void testSqlTime() { // millis since epoch serializeAndEqualityCheck( TypedValue.ofLocal(Rep.JAVA_SQL_TIME, 42 * 1024 * 1024)); }
@Test public void testSqlDate() { // days since epoch serializeAndEqualityCheck(TypedValue.ofLocal(Rep.JAVA_SQL_DATE, 25)); }
@Test public void testSqlTime() { // millis since epoch serializeAndEqualityCheck( TypedValue.ofLocal(Rep.JAVA_SQL_TIME, 42 * 1024 * 1024)); }
@Test public void testSqlTimestamp() { serializeAndEqualityCheck( TypedValue.ofLocal(Rep.JAVA_SQL_TIMESTAMP, 42L * 1024 * 1024 * 1024)); } }
@Test public void testByteString() { serializeAndEqualityCheck( TypedValue.ofLocal(Rep.BYTE_STRING, new ByteString("qwertyasdf".getBytes(UTF_8)))); }
@Test public void testByteString() { serializeAndEqualityCheck( TypedValue.ofLocal(Rep.BYTE_STRING, new ByteString("qwertyasdf".getBytes(StandardCharsets.UTF_8)))); }
@Test public void testDecimal() { final BigDecimal decimal = new BigDecimal("1.2345"); final TypedValue decimalTypedValue = TypedValue.ofLocal(Rep.NUMBER, decimal); serializeAndEqualityCheck(decimalTypedValue); final Common.TypedValue protoTypedValue = decimalTypedValue.toProto(); assertEquals(Common.Rep.BIG_DECIMAL, protoTypedValue.getType()); final String strValue = protoTypedValue.getStringValue(); assertNotNull(strValue); assertEquals(decimal.toPlainString(), strValue); }