use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class TestJavaType method testEnumType.
public void testEnumType() {
TypeFactory tf = TypeFactory.defaultInstance();
JavaType enumT = tf.constructType(MyEnum.class);
assertTrue(enumT.isEnumType());
assertFalse(enumT.hasHandlers());
assertTrue(enumT.isTypeOrSubTypeOf(MyEnum.class));
assertTrue(enumT.isTypeOrSubTypeOf(Object.class));
assertNull(enumT.containedType(3));
assertTrue(enumT.containedTypeOrUnknown(3).isJavaLangObject());
assertEquals("Lcom/fasterxml/jackson/databind/type/TestJavaType$MyEnum;", enumT.getGenericSignature());
assertEquals("Lcom/fasterxml/jackson/databind/type/TestJavaType$MyEnum;", enumT.getErasedSignature());
assertTrue(tf.constructType(MyEnum2.class).isEnumType());
assertTrue(tf.constructType(MyEnum.A.getClass()).isEnumType());
assertTrue(tf.constructType(MyEnum2.A.getClass()).isEnumType());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class TestJavaType method testGenericSignature1194.
// [databind#1194]
public void testGenericSignature1194() throws Exception {
TypeFactory tf = TypeFactory.defaultInstance();
Method m;
JavaType t;
m = Generic1194.class.getMethod("getList");
t = tf.constructType(m.getGenericReturnType());
assertEquals("Ljava/util/List<Ljava/lang/String;>;", t.getGenericSignature());
assertEquals("Ljava/util/List;", t.getErasedSignature());
m = Generic1194.class.getMethod("getMap");
t = tf.constructType(m.getGenericReturnType());
assertEquals("Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;", t.getGenericSignature());
m = Generic1194.class.getMethod("getGeneric");
t = tf.constructType(m.getGenericReturnType());
assertEquals("Ljava/util/concurrent/atomic/AtomicReference<Ljava/lang/String;>;", t.getGenericSignature());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class TestJavaType method testArrayType.
public void testArrayType() {
TypeFactory tf = TypeFactory.defaultInstance();
JavaType arrayT = ArrayType.construct(tf.constructType(String.class), null);
assertNotNull(arrayT);
assertTrue(arrayT.isContainerType());
assertFalse(arrayT.isReferenceType());
assertTrue(arrayT.hasContentType());
assertNotNull(arrayT.toString());
assertNotNull(arrayT.getContentType());
assertNull(arrayT.getKeyType());
assertTrue(arrayT.equals(arrayT));
assertFalse(arrayT.equals(null));
assertFalse(arrayT.equals("xyz"));
assertTrue(arrayT.equals(ArrayType.construct(tf.constructType(String.class), null)));
assertFalse(arrayT.equals(ArrayType.construct(tf.constructType(Integer.class), null)));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class TestJavaType method testJavaTypeAsJLRType.
// [databind#116]
public void testJavaTypeAsJLRType() {
TypeFactory tf = TypeFactory.defaultInstance();
JavaType t1 = tf.constructType(getClass());
// should just get it back as-is:
JavaType t2 = tf.constructType(t1);
assertSame(t1, t2);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project beam by apache.
the class ProxyInvocationHandler method getValueFromJson.
/**
* Uses a Jackson {@link ObjectMapper} to attempt type conversion.
*
* @param method The method whose return type you would like to return.
* @param propertyName The name of the property that is being returned.
* @return An object matching the return type of the method passed in.
*/
private Object getValueFromJson(String propertyName, Method method) {
try {
JavaType type = PipelineOptionsFactory.MAPPER.getTypeFactory().constructType(method.getGenericReturnType());
JsonNode jsonNode = jsonOptions.get(propertyName);
return PipelineOptionsFactory.MAPPER.readValue(jsonNode.toString(), type);
} catch (IOException e) {
throw new RuntimeException("Unable to parse representation", e);
}
}
Aggregations