|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.jackson.map.type.TypeFactory
public class TypeFactory
Class used for constracting concrete JavaType
instances,
given various inputs.
Typical usage patterns is 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(Integer.class)to represent
Map<String,Integer>This is an alternative to using
TypeReference
that would
be something like
new TypeReference<Map<String,Integer>>() { }
Field Summary | |
---|---|
static TypeFactory |
instance
|
Method Summary | ||
---|---|---|
protected
|
_findParentType(Class<?> clz,
Class<T> expType)
Method that is to figure out actual type parameters that given class binds to generic types defined by given interface type. |
|
protected JavaType |
_fromArrayType(GenericArrayType type,
JavaType context)
|
|
protected JavaType |
_fromClass(Class<?> clz,
Map<String,JavaType> genericParams)
|
|
protected JavaType |
_fromParamType(ParameterizedType type,
JavaType context)
This method deals with parameterized types, that is, first class generic classes. |
|
JavaType |
_fromType(Type type,
JavaType 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 JavaType |
_fromVariable(TypeVariable<?> type,
JavaType context)
|
|
protected JavaType |
_fromWildcard(WildcardType type,
JavaType context)
|
|
protected JavaType |
_unknownType()
|
|
static JavaType |
arrayType(Class<?> elementType)
Convenience factory method for constructing JavaType that
represent array that contains elements
of specified type. |
|
static JavaType |
arrayType(JavaType elementType)
Convenience factory method for constructing JavaType that
represent array that contains elements
of specified type. |
|
static JavaType |
collectionType(Class<? extends Collection> collectionType,
Class<?> elementType)
Convenience factory method for constructing JavaType that
represent Collection of specified type and contains elements
of specified type |
|
static JavaType |
collectionType(Class<? extends Collection> collectionType,
JavaType elementType)
Convenience factory method for constructing JavaType that
represent Collection of specified type and contains elements
of specified type |
|
static JavaType |
fromClass(Class<?> clz)
Deprecated. Use type(Type) instead |
|
static JavaType |
fromType(Type type)
Deprecated. Use type(Type) instead |
|
static JavaType |
fromType(Type type,
JavaType context)
Deprecated. Use type(Type,JavaType) instead |
|
static JavaType |
fromTypeReference(TypeReference<?> ref)
Deprecated. Use type(Type) instead |
|
static JavaType |
mapType(Class<? extends Map> mapType,
Class<?> keyType,
Class<?> valueType)
Convenience factory method for constructing JavaType that
represent Map of specified type and contains elements
of specified type |
|
static JavaType |
mapType(Class<? extends Map> mapType,
JavaType keyType,
JavaType valueType)
Convenience factory method for constructing JavaType that
represent Map of specified type and contains elements
of specified type |
|
static JavaType |
type(Type t)
Factory method for constructing JavaType from given
"raw" type; which may be anything from simple Class
to full generic type. |
|
static JavaType |
type(Type type,
JavaType context)
Factory method that can use given context to resolve named generic types. |
|
static JavaType |
type(TypeReference<?> ref)
Factory method that can be used if the full generic type has been passed using TypeReference . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final TypeFactory instance
Method Detail |
---|
public static JavaType type(Type t)
JavaType
from given
"raw" type; which may be anything from simple Class
to full generic type.
public static JavaType type(Type type, JavaType context)
context
- Type context that can be used for binding
named formal type parameters, if any (if null, no context
is used)public static JavaType type(TypeReference<?> ref)
TypeReference
. This only needs to be
done if the root type to bind to is generic; but if so,
it must be done to get proper typing.
public static JavaType arrayType(Class<?> elementType)
JavaType
that
represent array that contains elements
of specified type.
public static JavaType arrayType(JavaType elementType)
JavaType
that
represent array that contains elements
of specified type.
public static JavaType collectionType(Class<? extends Collection> collectionType, Class<?> elementType)
JavaType
that
represent Collection of specified type and contains elements
of specified type
public static JavaType collectionType(Class<? extends Collection> collectionType, JavaType elementType)
JavaType
that
represent Collection of specified type and contains elements
of specified type
public static JavaType mapType(Class<? extends Map> mapType, Class<?> keyType, Class<?> valueType)
JavaType
that
represent Map of specified type and contains elements
of specified type
public static JavaType mapType(Class<? extends Map> mapType, JavaType keyType, JavaType valueType)
JavaType
that
represent Map of specified type and contains elements
of specified type
public static JavaType fromClass(Class<?> clz)
type(Type)
instead
Class
. This means that there
will not be generic type information due to type erasure,
but at least it will be possible to recognize array
types and non-typed container types.
And for other types (primitives/wrappers, beans), this
is all that is needed.
public static JavaType fromTypeReference(TypeReference<?> ref)
type(Type)
instead
TypeReference
. This only needs to be
done if the root type to bind to is generic; but if so,
it must be done to get proper typing.
public static JavaType fromType(Type type)
type(Type)
instead
getGenericXxx
methods
(usually for a return or argument type).
public static JavaType fromType(Type type, JavaType context)
type(Type,JavaType)
instead
context
- Type context that can be used for binding
named formal type parameters, if any (if null, no context
is used)protected JavaType _fromClass(Class<?> clz, Map<String,JavaType> genericParams)
genericParams
- Mapping of formal parameter declarations (for generic
types) into actual typespublic JavaType _fromType(Type type, JavaType context)
getGenericXxx
methods
(usually for a return or argument type).
protected JavaType _fromParamType(ParameterizedType type, JavaType context)
Since version 1.2, this resolves all generics types, not just Maps or Collections.
protected JavaType _fromArrayType(GenericArrayType type, JavaType context)
protected JavaType _fromVariable(TypeVariable<?> type, JavaType context)
protected JavaType _fromWildcard(WildcardType type, JavaType context)
protected <T extends JavaType> T _findParentType(Class<?> clz, Class<T> expType)
protected JavaType _unknownType()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |