use of com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class TestTypeResolution method testGeneric.
public void testGeneric() {
TypeFactory tf = TypeFactory.defaultInstance();
// First, via simple sub-class
JavaType t = tf.constructType(DoubleRange.class);
JavaType rangeParams = t.findSuperType(Range.class);
assertEquals(1, rangeParams.containedTypeCount());
assertEquals(Double.class, rangeParams.containedType(0).getRawClass());
// then using TypeRef
t = tf.constructType(new TypeReference<DoubleRange>() {
});
rangeParams = t.findSuperType(Range.class);
assertEquals(1, rangeParams.containedTypeCount());
assertEquals(Double.class, rangeParams.containedType(0).getRawClass());
}
use of com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class TestJavaType method testSimpleClass.
public void testSimpleClass() {
TypeFactory tf = TypeFactory.defaultInstance();
JavaType baseType = tf.constructType(BaseType.class);
assertSame(BaseType.class, baseType.getRawClass());
assertTrue(baseType.hasRawClass(BaseType.class));
assertFalse(baseType.isTypeOrSubTypeOf(SubType.class));
assertFalse(baseType.isArrayType());
assertFalse(baseType.isContainerType());
assertFalse(baseType.isEnumType());
assertFalse(baseType.isInterface());
assertFalse(baseType.isPrimitive());
assertFalse(baseType.isReferenceType());
assertFalse(baseType.hasContentType());
assertNull(baseType.getContentType());
assertNull(baseType.getKeyType());
assertNull(baseType.getValueHandler());
assertEquals("Lcom/fasterxml/jackson/databind/type/TestJavaType$BaseType;", baseType.getGenericSignature());
assertEquals("Lcom/fasterxml/jackson/databind/type/TestJavaType$BaseType;", baseType.getErasedSignature());
}
use of com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class TestJavaType method testDeprecated.
@SuppressWarnings("deprecation")
public void testDeprecated() {
TypeFactory tf = TypeFactory.defaultInstance();
JavaType baseType = tf.constructType(BaseType.class);
assertTrue(baseType.hasRawClass(BaseType.class));
assertNull(baseType.getParameterSource());
assertNull(baseType.getContentTypeHandler());
assertNull(baseType.getContentValueHandler());
assertFalse(baseType.hasValueHandler());
assertFalse(baseType.hasHandlers());
assertSame(baseType, baseType.forcedNarrowBy(BaseType.class));
JavaType sub = baseType.forcedNarrowBy(SubType.class);
assertTrue(sub.hasRawClass(SubType.class));
}
use of com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class TestJavaType method testMapType.
public void testMapType() {
TypeFactory tf = TypeFactory.defaultInstance();
JavaType mapT = tf.constructType(HashMap.class);
assertTrue(mapT.isContainerType());
assertFalse(mapT.isReferenceType());
assertTrue(mapT.hasContentType());
assertNotNull(mapT.toString());
assertNotNull(mapT.getContentType());
assertNotNull(mapT.getKeyType());
assertEquals("Ljava/util/HashMap<Ljava/lang/Object;Ljava/lang/Object;>;", mapT.getGenericSignature());
assertEquals("Ljava/util/HashMap;", mapT.getErasedSignature());
assertTrue(mapT.equals(mapT));
assertFalse(mapT.equals(null));
assertFalse(mapT.equals("xyz"));
}
use of com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class TestJavaType method testAnchorTypeForRefTypes.
public void testAnchorTypeForRefTypes() throws Exception {
TypeFactory tf = TypeFactory.defaultInstance();
JavaType t = tf.constructType(AtomicStringReference.class);
assertTrue(t.isReferenceType());
assertTrue(t.hasContentType());
ReferenceType rt = (ReferenceType) t;
assertFalse(rt.isAnchorType());
assertEquals(AtomicReference.class, rt.getAnchorType().getRawClass());
}
Aggregations