private <T> void assertDecodeValue(Buffer buffer, T expected, TypeReference<T> ref) { Type type = ref.getType(); Class<?> clazz = type instanceof Class ? (Class<?>) type : (Class<?>) ((ParameterizedType) type).getRawType(); assertEquals(expected, Json.decodeValue(buffer, clazz)); assertEquals(expected, Json.decodeValue(buffer, ref)); assertEquals(expected, Json.decodeValue(buffer.toString(StandardCharsets.UTF_8), clazz)); assertEquals(expected, Json.decodeValue(buffer.toString(StandardCharsets.UTF_8), ref)); Buffer nullValue = Buffer.buffer("null"); assertNull(Json.decodeValue(nullValue, clazz)); assertNull(Json.decodeValue(nullValue, ref)); assertNull(Json.decodeValue(nullValue.toString(StandardCharsets.UTF_8), clazz)); assertNull(Json.decodeValue(nullValue.toString(StandardCharsets.UTF_8), ref)); } }
private <T> void assertDecodeValue(Buffer buffer, T expected, TypeReference<T> ref) { Type type = ref.getType(); Class<?> clazz = type instanceof Class ? (Class<?>) type : (Class<?>) ((ParameterizedType) type).getRawType(); assertEquals(expected, Json.decodeValue(buffer, clazz)); assertEquals(expected, Json.decodeValue(buffer, ref)); assertEquals(expected, Json.decodeValue(buffer.toString(StandardCharsets.UTF_8), clazz)); assertEquals(expected, Json.decodeValue(buffer.toString(StandardCharsets.UTF_8), ref)); Buffer nullValue = Buffer.buffer("null"); assertNull(Json.decodeValue(nullValue, clazz)); assertNull(Json.decodeValue(nullValue, ref)); assertNull(Json.decodeValue(nullValue.toString(StandardCharsets.UTF_8), clazz)); assertNull(Json.decodeValue(nullValue.toString(StandardCharsets.UTF_8), ref)); } }