|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.jackson.type.JavaType
public abstract class JavaType
Base class for type token classes used both to contain information and as keys for deserializers.
Instances can (only) be constructed by
TypeFactory
.
Field Summary | |
---|---|
protected Class<?> |
_class
This is the nominal type-erased Class that would be close to the type represented (but not exactly type, due to type erasure: type instance may have more information on this). |
protected int |
_hashCode
|
protected Object |
_typeHandler
Optional handler that can be attached to indicate how to handle additional type metadata associated with this type. |
protected Object |
_valueHandler
Optional handler (codec) that can be attached to indicate what to use for handling (serializing, deserializing) values of this specific type. |
Constructor Summary | |
---|---|
protected |
JavaType(Class<?> raw,
int additionalHash)
|
Method Summary | ||
---|---|---|
protected void |
_assertSubclass(Class<?> subclass,
Class<?> superClass)
|
|
protected abstract JavaType |
_narrow(Class<?> subclass)
|
|
protected JavaType |
_widen(Class<?> superclass)
Default implementation is just to call _narrow(java.lang.Class>) , since
underlying type construction is usually identical |
|
JavaType |
containedType(int index)
Method for accessing definitions of contained ("child") types. |
|
int |
containedTypeCount()
Method for checking how many contained types this type has. |
|
String |
containedTypeName(int index)
Method for accessing name of type variable in indicated position. |
|
abstract boolean |
equals(Object o)
|
|
JavaType |
forcedNarrowBy(Class<?> subclass)
More efficient version of narrowBy(java.lang.Class>) , called by
internal framework in cases where compatibility checks
are to be skipped. |
|
JavaType |
getContentType()
Method for accessing content type of this type, if type has such a thing: simple types do not, structured types do (like arrays, Collections and Maps) |
|
String |
getErasedSignature()
Method for accessing signature without generic type information, in form compatible with all versions of JVM, and specifically used for type descriptions when generating byte code. |
|
abstract StringBuilder |
getErasedSignature(StringBuilder sb)
Method for accessing signature without generic type information, in form compatible with all versions of JVM, and specifically used for type descriptions when generating byte code. |
|
String |
getGenericSignature()
Method for accessing signature that contains generic type information, in form compatible with JVM 1.5 as per JLS. |
|
abstract StringBuilder |
getGenericSignature(StringBuilder sb)
|
|
JavaType |
getKeyType()
Method for accessing key type for this type, assuming type has such a concept (only Map types do) |
|
Class<?> |
getRawClass()
|
|
|
getTypeHandler()
Method for accessing type handler associated with this type, if any |
|
|
getValueHandler()
Method for accessing value handler associated with this type, if any |
|
boolean |
hasGenericTypes()
Method that can be used to find out if the type directly declares generic parameters (for its direct super-class and/or super-interfaces). |
|
int |
hashCode()
|
|
boolean |
hasRawClass(Class<?> clz)
Method that can be used to check whether this type has specified Class as its type erasure. |
|
boolean |
isAbstract()
|
|
boolean |
isArrayType()
|
|
boolean |
isCollectionLikeType()
|
|
boolean |
isConcrete()
|
|
abstract boolean |
isContainerType()
|
|
boolean |
isEnumType()
|
|
boolean |
isFinal()
|
|
boolean |
isInterface()
|
|
boolean |
isMapLikeType()
|
|
boolean |
isPrimitive()
|
|
boolean |
isThrowable()
|
|
JavaType |
narrowBy(Class<?> subclass)
Method that can be called to do a "narrowing" conversions; that is, to return a type with a raw class that is assignable to the raw class of this type. |
|
abstract JavaType |
narrowContentsBy(Class<?> contentClass)
|
|
void |
setValueHandler(Object h)
Deprecated. Since 1.9, should not be used; instead, use withContentTypeHandler and
withContentValueHandler methods. |
|
abstract String |
toCanonical()
Method that can be used to serialize type into form from which it can be fully deserialized from at a later point (using TypeFactory from mapper package). |
|
abstract String |
toString()
|
|
JavaType |
widenBy(Class<?> superclass)
Method that can be called to do a "widening" conversions; that is, to return a type with a raw class that could be assigned from this type. |
|
abstract JavaType |
widenContentsBy(Class<?> contentClass)
|
|
abstract JavaType |
withContentTypeHandler(Object h)
"Copy method" that will construct a new instance that is identical to this instance, except that its content type will have specified type handler assigned. |
|
JavaType |
withContentValueHandler(Object h)
|
|
abstract JavaType |
withTypeHandler(Object h)
"Copy method" that will construct a new instance that is identical to this instance, except that it will have specified type handler assigned. |
|
JavaType |
withValueHandler(Object h)
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final Class<?> _class
protected final int _hashCode
protected Object _valueHandler
Note: untyped (i.e. caller has to cast) because it is used for different kinds of handlers, with unrelated types.
TODO: make final and possible promote to sub-classes
protected Object _typeHandler
Note: untyped (i.e. caller has to cast) because it is used for different kinds of handlers, with unrelated types.
TODO: make final and possible promote to sub-classes
Constructor Detail |
---|
protected JavaType(Class<?> raw, int additionalHash)
raw
- "Raw" (type-erased) class for this typeadditionalHash
- Additional hash code to use, in addition
to hash code of the class nameMethod Detail |
---|
public abstract JavaType withTypeHandler(Object h)
public abstract JavaType withContentTypeHandler(Object h)
public JavaType withValueHandler(Object h)
public JavaType withContentValueHandler(Object h)
@Deprecated public void setValueHandler(Object h)
withContentTypeHandler
and
withContentValueHandler
methods.
public JavaType narrowBy(Class<?> subclass)
IllegalArgumentException
is thrown.
If class is same as the current raw class, instance itself is
returned.
public JavaType forcedNarrowBy(Class<?> subclass)
narrowBy(java.lang.Class>)
, called by
internal framework in cases where compatibility checks
are to be skipped.
public JavaType widenBy(Class<?> superclass)
IllegalArgumentException
is thrown.
If class is same as the current raw class, instance itself is
returned.
protected abstract JavaType _narrow(Class<?> subclass)
protected JavaType _widen(Class<?> superclass)
Default implementation is just to call _narrow(java.lang.Class>)
, since
underlying type construction is usually identical
public abstract JavaType narrowContentsBy(Class<?> contentClass)
public abstract JavaType widenContentsBy(Class<?> contentClass)
public final Class<?> getRawClass()
public final boolean hasRawClass(Class<?> clz)
public boolean isAbstract()
public boolean isConcrete()
public boolean isThrowable()
public boolean isArrayType()
public final boolean isEnumType()
public final boolean isInterface()
public final boolean isPrimitive()
public final boolean isFinal()
public abstract boolean isContainerType()
public boolean isCollectionLikeType()
Collection
type,
or something similar (meaning it has at least one type parameter,
which describes type of contents)public boolean isMapLikeType()
Map
type,
or something similar (meaning it has at least two type parameter;
first one describing key type, second value type)public boolean hasGenericTypes()
public JavaType getKeyType()
public JavaType getContentType()
public int containedTypeCount()
public JavaType containedType(int index)
index
- Index of contained type to return
public String containedTypeName(int index)
index
- Index of contained type to return
public <T> T getValueHandler()
public <T> T getTypeHandler()
public abstract String toCanonical()
TypeFactory
from mapper package).
For simple types this is same as calling
Class.getName()
, but for structured types it may additionally
contain type information about contents.
public String getGenericSignature()
getErasedSignature()
,
in that generic information can be automatically removed
if necessary (just remove outermost
angle brackets along with content inside)
public abstract StringBuilder getGenericSignature(StringBuilder sb)
sb
- StringBuilder to append signature to
public String getErasedSignature()
public abstract StringBuilder getErasedSignature(StringBuilder sb)
sb
- StringBuilder to append signature to
protected void _assertSubclass(Class<?> subclass, Class<?> superClass)
public abstract String toString()
toString
in class Object
public abstract boolean equals(Object o)
equals
in class Object
public final int hashCode()
hashCode
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |