public final class TypeFactory extends Object
JavaType instances,
given various inputs.
As of Jackson 1.8, usage should be done using instance configured
via ObjectMapper (and exposed through
DeserializationConfig and
SerializationConfig).
However, old static-singleton access methods are supported as well; however,
using those may cause issues with extension modules that register
"type enchancers".
Typical usage pattern before Jackson 1.8 was to statically import factory methods
of this class, to allow convenient instantiation of structured
types, especially Collection and Map types
to represent generic types. For example
mapType(String.class, Integer.class)to represent
Map<String,Integer>This is an alternative to using
TypeReference that would
be something like
new TypeReference<Map<String,Integer>>() { }
| Modifier and Type | Field and Description |
|---|---|
protected HierarchicType |
_cachedArrayListType
Lazily constructed copy of type hierarchy from
ArrayList
to its supertypes. |
protected HierarchicType |
_cachedHashMapType
Lazily constructed copy of type hierarchy from
HashMap
to its supertypes. |
protected TypeModifier[] |
_modifiers
Registered
TypeModifiers: objects that can change details
of JavaType instances factory constructs. |
protected TypeParser |
_parser |
static TypeFactory |
instance
Deprecated.
As of 1.8, should use a per-ObjectMapper instance instead
of global singleton
|
| Modifier | Constructor and Description |
|---|---|
protected |
TypeFactory(TypeParser p,
TypeModifier[] mods) |
| Modifier and Type | Method and Description |
|---|---|
protected HierarchicType |
_arrayListSuperInterfaceChain(HierarchicType current) |
JavaType |
_constructType(Type type,
TypeBindings context)
Factory method that can be used if type information is passed
as Java typing returned from
getGenericXxx methods
(usually for a return or argument type). |
protected HierarchicType |
_doFindSuperInterfaceChain(HierarchicType current,
Class<?> target) |
protected HierarchicType |
_findSuperClassChain(Type currentType,
Class<?> target) |
protected HierarchicType |
_findSuperInterfaceChain(Type currentType,
Class<?> target) |
protected HierarchicType |
_findSuperTypeChain(Class<?> subtype,
Class<?> supertype)
Helper method used to find inheritance (implements, extends) path
between given types, if one exists (caller generally checks before
calling this method).
|
protected JavaType |
_fromArrayType(GenericArrayType type,
TypeBindings context) |
protected JavaType |
_fromClass(Class<?> clz,
TypeBindings context) |
protected JavaType |
_fromParameterizedClass(Class<?> clz,
List<JavaType> paramTypes)
Method used by
TypeParser when generics-aware version
is constructed. |
protected JavaType |
_fromParamType(ParameterizedType type,
TypeBindings context)
This method deals with parameterized types, that is,
first class generic classes.
|
protected JavaType |
_fromVariable(TypeVariable<?> type,
TypeBindings context) |
protected JavaType |
_fromWildcard(WildcardType type,
TypeBindings context) |
protected HierarchicType |
_hashMapSuperInterfaceChain(HierarchicType current) |
protected JavaType |
_resolveVariableViaSubTypes(HierarchicType leafType,
String variableName,
TypeBindings bindings) |
protected JavaType |
_unknownType() |
static JavaType |
arrayType(Class<?> elementType)
Deprecated.
|
static JavaType |
arrayType(JavaType elementType)
Deprecated.
|
static JavaType |
collectionType(Class<? extends Collection> collectionType,
Class<?> elementType)
Deprecated.
|
static JavaType |
collectionType(Class<? extends Collection> collectionType,
JavaType elementType)
Deprecated.
|
ArrayType |
constructArrayType(Class<?> elementType)
Method for constructing an
ArrayType. |
ArrayType |
constructArrayType(JavaType elementType)
Method for constructing an
ArrayType. |
CollectionLikeType |
constructCollectionLikeType(Class<?> collectionClass,
Class<?> elementClass)
Method for constructing a
CollectionLikeType. |
CollectionLikeType |
constructCollectionLikeType(Class<?> collectionClass,
JavaType elementType)
Method for constructing a
CollectionLikeType. |
CollectionType |
constructCollectionType(Class<? extends Collection> collectionClass,
Class<?> elementClass)
Method for constructing a
CollectionType. |
CollectionType |
constructCollectionType(Class<? extends Collection> collectionClass,
JavaType elementType)
Method for constructing a
CollectionType. |
JavaType |
constructFromCanonical(String canonical)
Factory method for constructing a
JavaType out of its canonical
representation (see JavaType.toCanonical()). |
MapLikeType |
constructMapLikeType(Class<?> mapClass,
Class<?> keyClass,
Class<?> valueClass)
Method for constructing a
MapLikeType instance |
MapLikeType |
constructMapLikeType(Class<?> mapClass,
JavaType keyType,
JavaType valueType)
Method for constructing a
MapLikeType instance |
MapType |
constructMapType(Class<? extends Map> mapClass,
Class<?> keyClass,
Class<?> valueClass)
Method for constructing a
MapType instance |
MapType |
constructMapType(Class<? extends Map> mapClass,
JavaType keyType,
JavaType valueType)
Method for constructing a
MapType instance |
JavaType |
constructParametricType(Class<?> parametrized,
Class<?>... parameterClasses)
Factory method for constructing
JavaType that
represents a parameterized type. |
JavaType |
constructParametricType(Class<?> parametrized,
JavaType... parameterTypes)
Factory method for constructing
JavaType that
represents a parameterized type. |
CollectionLikeType |
constructRawCollectionLikeType(Class<?> collectionClass)
Method that can be used to construct "raw" Collection-like type; meaning that its
parameterization is unknown.
|
CollectionType |
constructRawCollectionType(Class<? extends Collection> collectionClass)
Method that can be used to construct "raw" Collection type; meaning that its
parameterization is unknown.
|
MapLikeType |
constructRawMapLikeType(Class<?> mapClass)
Method that can be used to construct "raw" Map-like type; meaning that its
parameterization is unknown.
|
MapType |
constructRawMapType(Class<? extends Map> mapClass)
Method that can be used to construct "raw" Map type; meaning that its
parameterization is unknown.
|
JavaType |
constructSimpleType(Class<?> rawType,
JavaType[] parameterTypes)
Method for constructing a type instance with specified parameterization.
|
JavaType |
constructSpecializedType(JavaType baseType,
Class<?> subclass)
Factory method for creating a subtype of given base type, as defined
by specified subclass; but retaining generic type information if any.
|
JavaType |
constructType(Type type) |
JavaType |
constructType(Type type,
Class<?> context) |
JavaType |
constructType(Type type,
JavaType context) |
JavaType |
constructType(TypeReference<?> typeRef) |
JavaType |
constructType(Type type,
TypeBindings bindings) |
static TypeFactory |
defaultInstance()
Method used to access the globally shared instance, which has
no custom configuration.
|
static JavaType |
fastSimpleType(Class<?> cls)
Deprecated.
|
static JavaType[] |
|