use of com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class TypeFactory method _mapType.
/*
/**********************************************************
/* Low-level factory methods
/**********************************************************
*/
private JavaType _mapType(Class<?> rawClass, TypeBindings bindings, JavaType superClass, JavaType[] superInterfaces) {
JavaType kt, vt;
// 28-May-2015, tatu: Properties are special, as per [databind#810]; fake "correct" parameter sig
if (rawClass == Properties.class) {
kt = vt = CORE_TYPE_STRING;
} else {
List<JavaType> typeParams = bindings.getTypeParameters();
// ok to have no types ("raw")
switch(typeParams.size()) {
case // acceptable?
0:
kt = vt = _unknownType();
break;
case 2:
kt = typeParams.get(0);
vt = typeParams.get(1);
break;
default:
throw new IllegalArgumentException("Strange Map type " + rawClass.getName() + ": can not determine type parameters");
}
}
return MapType.construct(rawClass, bindings, superClass, superInterfaces, kt, vt);
}
use of com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class JsonLocationInstantiator method getFromObjectArguments.
@Override
public SettableBeanProperty[] getFromObjectArguments(DeserializationConfig config) {
JavaType intType = config.constructType(Integer.TYPE);
JavaType longType = config.constructType(Long.TYPE);
return new SettableBeanProperty[] { creatorProp("sourceRef", config.constructType(Object.class), 0), creatorProp("byteOffset", longType, 1), creatorProp("charOffset", longType, 2), creatorProp("lineNr", intType, 3), creatorProp("columnNr", intType, 4) };
}
use of com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class AnnotatedClass method _findFields.
/*
/**********************************************************
/* Helper methods for populating field information
/**********************************************************
*/
protected Map<String, AnnotatedField> _findFields(JavaType type, TypeResolutionContext typeContext, Map<String, AnnotatedField> fields) {
/* First, a quick test: we only care for regular classes (not
* interfaces, primitive types etc), except for Object.class.
* A simple check to rule out other cases is to see if there
* is a super class or not.
*/
JavaType parent = type.getSuperClass();
if (parent != null) {
final Class<?> cls = type.getRawClass();
// Let's add super-class' fields first, then ours.
/* 21-Feb-2010, tatu: Need to handle masking: as per [JACKSON-226]
* we otherwise get into trouble...
*/
fields = _findFields(parent, new TypeResolutionContext.Basic(_typeFactory, parent.getBindings()), fields);
for (Field f : ClassUtil.getDeclaredFields(cls)) {
// static fields not included (transients are at this point, filtered out later)
if (!_isIncludableField(f)) {
continue;
}
/* Ok now: we can (and need) not filter out ignorable fields
* at this point; partly because mix-ins haven't been
* added, and partly because logic can be done when
* determining get/settability of the field.
*/
if (fields == null) {
fields = new LinkedHashMap<String, AnnotatedField>();
}
fields.put(f.getName(), _constructField(f, typeContext));
}
// And then... any mix-in overrides?
if (_mixInResolver != null) {
Class<?> mixin = _mixInResolver.findMixInClassFor(cls);
if (mixin != null) {
_addFieldMixIns(mixin, cls, fields);
}
}
}
return fields;
}
use of com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class TestJavaType method testObjectToReferenceSpecialization.
// for [databind#1290]
public void testObjectToReferenceSpecialization() throws Exception {
TypeFactory tf = TypeFactory.defaultInstance();
JavaType base = tf.constructType(Object.class);
assertTrue(base.isJavaLangObject());
JavaType sub = tf.constructSpecializedType(base, AtomicReference.class);
assertEquals(AtomicReference.class, sub.getRawClass());
assertTrue(sub.isReferenceType());
}
use of com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class TestJavaType method testLocalType728.
/*
/**********************************************************
/* Test methods
/**********************************************************
*/
public void testLocalType728() throws Exception {
TypeFactory tf = TypeFactory.defaultInstance();
Method m = Issue728.class.getMethod("method", CharSequence.class);
assertNotNull(m);
// Start with return type
// first type-erased
JavaType t = tf.constructType(m.getReturnType());
assertEquals(CharSequence.class, t.getRawClass());
// then generic
t = tf.constructType(m.getGenericReturnType());
assertEquals(CharSequence.class, t.getRawClass());
// then parameter type
t = tf.constructType(m.getParameterTypes()[0]);
assertEquals(CharSequence.class, t.getRawClass());
t = tf.constructType(m.getGenericParameterTypes()[0]);
assertEquals(CharSequence.class, t.getRawClass());
}
Aggregations