public abstract class JavaType
extends com.fasterxml.jackson.core.type.ResolvedType
implements java.io.Serializable, java.lang.reflect.Type
Instances can (only) be constructed by
com.fasterxml.jackson.databind.TypeFactory.
Since 2.2 this implements Type to allow
it to be pushed through interfaces that only expose that type.
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
_asStatic
Whether entities defined with this type should be handled using
static typing (as opposed to dynamic runtime type) or not.
|
protected java.lang.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 java.lang.Object |
_typeHandler
Optional handler that can be attached to indicate how to handle
additional type metadata associated with this type.
|
protected java.lang.Object |
_valueHandler
Optional handler (codec) that can be attached to indicate
what to use for handling (serializing, deserializing) values of
this specific type.
|
| Modifier | Constructor and Description |
|---|---|
protected |
JavaType(java.lang.Class<?> raw,
int additionalHash,
java.lang.Object valueHandler,
java.lang.Object typeHandler,
boolean asStatic) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
_assertSubclass(java.lang.Class<?> subclass,
java.lang.Class<?> superClass) |
protected abstract JavaType |
_narrow(java.lang.Class<?> subclass) |
protected JavaType |
_widen(java.lang.Class<?> superclass)
Default implementation is just to call
_narrow(java.lang.Class<?>), since
underlying type construction is usually identical |
JavaType |
containedType(int index) |
int |
containedTypeCount() |
java.lang.String |
containedTypeName(int index) |
abstract boolean |
equals(java.lang.Object o) |
JavaType |
forcedNarrowBy(java.lang.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() |
java.lang.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 java.lang.StringBuilder |
getErasedSignature(java.lang.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.
|
java.lang.String |
getGenericSignature()
Method for accessing signature that contains generic
type information, in form compatible with JVM 1.5
as per JLS.
|
abstract java.lang.StringBuilder |
getGenericSignature(java.lang.StringBuilder sb) |
JavaType |
getKeyType() |
java.lang.Class<?> |
getRawClass() |
<T> T |
getTypeHandler()
Method for accessing type handler associated with this type, if any
|
<T> T |
getValueHandler()
Method for accessing value handler associated with this type, if any
|
boolean |
hasGenericTypes() |
int |
hashCode() |
boolean |
hasRawClass(java.lang.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()
Convenience method for checking whether underlying Java type
is a concrete class or not: abstract classes and interfaces
are not.
|
abstract boolean |
isContainerType() |
boolean |
isEnumType() |
boolean |
isFinal() |
boolean |
isInterface() |
boolean |
isMapLikeType() |
boolean |
isPrimitive() |
boolean |
isThrowable() |
JavaType |
narrowBy(java.lang.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(java.lang.Class<?> contentClass) |
abstract java.lang.String |
toString() |
boolean |
useStaticType()
Accessor for checking whether handlers for dealing with values of
this type should use static typing (as opposed to dynamic typing).
|
JavaType |
widenBy(java.lang.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(java.lang.Class<?> contentClass) |
abstract JavaType |
withContentTypeHandler(java.lang.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.
|
abstract JavaType |
withContentValueHandler(java.lang.Object h)
"Copy method" that will construct a new instance that is identical to
this instance, except that it will have specified content value handler assigned.
|
abstract JavaType |
withStaticTyping()
Method that can be called to get a type instance that indicates
that values of the type should be handled using "static typing" for purposes
of serialization (as opposed to "dynamic" aka runtime typing):
meaning that no runtime information is needed for determining serializers to use.
|
abstract JavaType |
withTypeHandler(java.lang.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.
|
abstract JavaType |
withValueHandler(java.lang.Object h)
"Copy method" that will construct a new instance that is identical to
this instance, except that it will have specified value handler assigned.
|
protected final java.lang.Class<?> _class
protected final int _hashCode
protected final java.lang.Object _valueHandler
Note: untyped (i.e. caller has to cast) because it is used for different kinds of handlers, with unrelated types.
protected final java.lang.Object _typeHandler
Note: untyped (i.e. caller has to cast) because it is used for different kinds of handlers, with unrelated types.
protected final boolean _asStatic
protected JavaType(java.lang.Class<?> raw,
int additionalHash,
java.lang.Object valueHandler,
java.lang.Object typeHandler,
boolean asStatic)
raw - "Raw" (type-erased) class for this typeadditionalHash - Additional hash code to use, in addition
to hash code of the class namepublic abstract JavaType withTypeHandler(java.lang.Object h)
public abstract JavaType withContentTypeHandler(java.lang.Object h)
public abstract JavaType withValueHandler(java.lang.Object h)
public abstract JavaType withContentValueHandler(java.lang.Object h)
public abstract JavaType withStaticTyping()
public JavaType narrowBy(java.lang.Class<?> subclass)
IllegalArgumentException is thrown.
If class is same as the current raw class, instance itself is
returned.public JavaType forcedNarrowBy(java.lang.Class<?> subclass)
narrowBy(java.lang.Class<?>), called by
internal framework in cases where compatibility checks
are to be skipped.public JavaType widenBy(java.lang.Class<?> superclass)
IllegalArgumentException is thrown.
If class is same as the current raw class, instance itself is
returned.protected abstract JavaType _narrow(java.lang.Class<?> subclass)
protected JavaType _widen(java.lang.Class<?> superclass)
Default implementation is just to call _narrow(java.lang.Class<?>), since
underlying type construction is usually identical
public abstract JavaType narrowContentsBy(java.lang.Class<?> contentClass)
public abstract JavaType widenContentsBy(java.lang.Class<?> contentClass)
public final java.lang.Class<?> getRawClass()
getRawClass in class com.fasterxml.jackson.core.type.ResolvedTypepublic final boolean hasRawClass(java.lang.Class<?> clz)
hasRawClass in class com.fasterxml.jackson.core.type.ResolvedTypepublic boolean isAbstract()
isAbstract in class com.fasterxml.jackson.core.type.ResolvedTypepublic boolean isConcrete()
isConcrete in class com.fasterxml.jackson.core.type.ResolvedTypepublic boolean isThrowable()
isThrowable in class com.fasterxml.jackson.core.type.ResolvedTypepublic boolean isArrayType()
isArrayType in class com.fasterxml.jackson.core.type.ResolvedTypepublic final boolean isEnumType()
isEnumType in class com.fasterxml.jackson.core.type.ResolvedTypepublic final boolean isInterface()
isInterface in class com.fasterxml.jackson.core.type.ResolvedTypepublic final boolean isPrimitive()
isPrimitive in class com.fasterxml.jackson.core.type.ResolvedTypepublic final boolean isFinal()
isFinal in class com.fasterxml.jackson.core.type.ResolvedTypepublic abstract boolean isContainerType()
isContainerType in class com.fasterxml.jackson.core.type.ResolvedTypepublic boolean isCollectionLikeType()
isCollectionLikeType in class com.fasterxml.jackson.core.type.ResolvedTypeCollection type,
or something similar (meaning it has at least one type parameter,
which describes type of contents)public boolean isMapLikeType()
isMapLikeType in class com.fasterxml.jackson.core.type.ResolvedTypeMap type,
or something similar (meaning it has at least two type parameter;
first one describing key type, second value type)public final boolean useStaticType()
public boolean hasGenericTypes()
hasGenericTypes in class com.fasterxml.jackson.core.type.ResolvedTypepublic JavaType getKeyType()
getKeyType in class com.fasterxml.jackson.core.type.ResolvedTypepublic JavaType getContentType()
getContentType in class com.fasterxml.jackson.core.type.ResolvedTypepublic int containedTypeCount()
containedTypeCount in class com.fasterxml.jackson.core.type.ResolvedTypepublic JavaType containedType(int index)
containedType in class com.fasterxml.jackson.core.type.ResolvedTypepublic java.lang.String containedTypeName(int index)
containedTypeName in class com.fasterxml.jackson.core.type.ResolvedTypepublic <T> T getValueHandler()
public <T> T getTypeHandler()
public java.lang.String getGenericSignature()
getErasedSignature(),
in that generic information can be automatically removed
if necessary (just remove outermost
angle brackets along with content inside)public abstract java.lang.StringBuilder getGenericSignature(java.lang.StringBuilder sb)
sb - StringBuilder to append signature topublic java.lang.String getErasedSignature()
public abstract java.lang.StringBuilder getErasedSignature(java.lang.StringBuilder sb)
sb - StringBuilder to append signature toprotected void _assertSubclass(java.lang.Class<?> subclass,
java.lang.Class<?> superClass)
public abstract java.lang.String toString()
toString in class java.lang.Objectpublic abstract boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic final int hashCode()
hashCode in class java.lang.ObjectCopyright © 2013. All Rights Reserved.