use of com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class TestTypeBindings method testRecursiveType.
// for [databind#76]
public void testRecursiveType() {
TypeFactory tf = TypeFactory.defaultInstance();
JavaType type = tf.constructType(HashTree.class);
assertNotNull(type);
}
use of com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class TestTypeBindings method testInnerType.
/*
/**********************************************************
/* Test methods
/**********************************************************
*/
public void testInnerType() throws Exception {
TypeFactory tf = TypeFactory.defaultInstance();
JavaType type = tf.constructType(InnerGenericTyping.InnerClass.class);
assertEquals(MapType.class, type.getClass());
JavaType keyType = type.getKeyType();
assertEquals(Object.class, keyType.getRawClass());
JavaType valueType = type.getContentType();
assertEquals(Collection.class, valueType.getRawClass());
JavaType vt2 = valueType.getContentType();
assertEquals(Object.class, vt2.getRawClass());
}
use of com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class TypeFactory method _referenceType.
private JavaType _referenceType(Class<?> rawClass, TypeBindings bindings, JavaType superClass, JavaType[] superInterfaces) {
List<JavaType> typeParams = bindings.getTypeParameters();
// ok to have no types ("raw")
JavaType ct;
if (typeParams.isEmpty()) {
ct = _unknownType();
} else if (typeParams.size() == 1) {
ct = typeParams.get(0);
} else {
throw new IllegalArgumentException("Strange Reference type " + rawClass.getName() + ": can not determine type parameters");
}
return ReferenceType.construct(rawClass, bindings, superClass, superInterfaces, ct);
}
use of com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class TypeFactory method _collectionType.
private JavaType _collectionType(Class<?> rawClass, TypeBindings bindings, JavaType superClass, JavaType[] superInterfaces) {
List<JavaType> typeParams = bindings.getTypeParameters();
// ok to have no types ("raw")
JavaType ct;
if (typeParams.isEmpty()) {
ct = _unknownType();
} else if (typeParams.size() == 1) {
ct = typeParams.get(0);
} else {
throw new IllegalArgumentException("Strange Collection type " + rawClass.getName() + ": can not determine type parameters");
}
return CollectionType.construct(rawClass, bindings, superClass, superInterfaces, ct);
}
use of com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class TypeFactory method _fromVariable.
protected JavaType _fromVariable(ClassStack context, TypeVariable<?> var, TypeBindings bindings) {
// ideally should find it via bindings:
final String name = var.getName();
JavaType type = bindings.findBoundType(name);
if (type != null) {
return type;
}
// into account possible multiple bounds, nor consider upper bounds.
if (bindings.hasUnbound(name)) {
return CORE_TYPE_OBJECT;
}
bindings = bindings.withUnboundVariable(name);
Type[] bounds = var.getBounds();
return _fromAny(context, bounds[0], bindings);
}
Aggregations