- All Implemented Interfaces:
Serializable,Type
- Direct Known Subclasses:
TypeBase
Instances can (only) be constructed by
TypeFactory.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanWhether entities defined with this type should be handled using static typing (as opposed to dynamic runtime type) or not.protected final 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 final intprotected final ObjectOptional handler that can be attached to indicate how to handle additional type metadata associated with this type.protected final ObjectOptional handler (codec) that can be attached to indicate what to use for handling (serializing, deserializing) values of this specific type. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract JavaTypecontainedType(int index) abstract intcontainedTypeOrUnknown(int index) Convenience method that is functionally same as:JavaType t = containedType(index); if (t == null) { t = TypeFactory.unknownType(); }and typically used to eliminate need for null checks for common case where we just want to check if containedType is available first; and if not, use "unknown type" (which translates tojava.lang.Objectbasically).abstract booleanabstract JavaTypefindSuperType(Class<?> erasedTarget) Method that may be called to find representation of given type within type hierarchy of this type: either this type (if this type has given erased type), one of its supertypes that has the erased types, or null if target is neither this type or any of its supertypes.abstract JavaType[]findTypeParameters(Class<?> expType) Method that may be used to find paramaterization this type has for given type-erased generic target type.abstract TypeBindingsInternal accessor that should not be used by any code outside of jackson-databind: only used internally by databind.Internal accessor that should not be used by any code outside of jackson-databind: only used internally by databind.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 StringBuilderMethod 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.Method for accessing signature that contains generic type information, in form compatible with JVM 1.5 as per JLS.abstract StringBuilderAccessor for finding fully resolved interfaces this type implements, if any; empty array if none.final Class<?>abstract JavaTypeAccessor for finding fully resolved parent class of this type, if it has one; null if not.Internal accessor that should not be used by any code outside of jackson-databind: only used internally by databind.Internal accessor that should not be used by any code outside of jackson-databind: only used internally by databind.booleanAccessor that allows determining whethergetContentType()should return a non-null value (that is, there is a "content type") or not.booleanbooleanHelper method that checks whether this type, or its (optional) key or content type hasgetValueHandler()orgetTypeHandler(); that is, are there any non-standard handlers associated with this type object.inthashCode()final booleanhasRawClass(Class<?> clz) Method that can be used to check whether this type has specified Class as its type erasure.booleanbooleanbooleanbooleanbooleanConvenience method for checking whether underlying Java type is a concrete class or not: abstract classes and interfaces are not.abstract booleanfinal booleanSimilar toisEnumType()except does NOT returntrueforEnum(since that is not Enum implementation type).final booleanMethod that basically does equivalent of:final booleanisFinal()final booleanbooleanMethod that returns true if this instance is of typeIterationType.final booleanConvenience method, short-hand forgetRawClass() == Object.classand used to figure if we basically have "untyped" type object.booleanfinal booleanfinal booleanbooleanfinal booleanisTypeOrSubTypeOf(Class<?> clz) final booleanisTypeOrSuperTypeOf(Class<?> clz) abstract JavaTyperefine(Class<?> rawType, TypeBindings bindings, JavaType superClass, JavaType[] superInterfaces) Mutant factory method that will try to create and return a sub-type instance for known parameterized types; for other types will return `null` to indicate that no just refinement makes necessary sense, without trying to detect special status through implemented interfaces.abstract StringtoString()final booleanAccessor for checking whether handlers for dealing with values of this type should use static typing (as opposed to dynamic typing).abstract JavaTypewithContentType(JavaType contentType) Mutant factory method that may be called on structured types that have a so-called content type (element of arrays, value type of Maps, referenced type of referential types), and will construct a new instance that is identical to this instance, except that it has specified content type, instead of current one.abstract JavaTypeInternal method that should not be used by any code outside of jackson-databind: only used internally by databind.abstract JavaTypeInternal method that should not be used by any code outside of jackson-databind: only used internally by databind.withHandlersFrom(JavaType src) Internal method that should not be used by any code outside of jackson-databind: only used internally by databind.abstract JavaTypeMethod 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 JavaTypeInternal method that should not be used by any code outside of jackson-databind: only used internally by databind.abstract JavaTypeInternal method that should not be used by any code outside of jackson-databind: only used internally by databind.Methods inherited from class tools.jackson.core.type.ResolvedType
isReferenceType, toCanonicalMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.reflect.Type
getTypeName
-
Field Details
-
_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). May be an interface or abstract class, so instantiation may not be possible. -
_hash
protected final int _hash -
_valueHandler
Optional handler (codec) that can be attached to indicate what to use for handling (serializing, deserializing) values of this specific type.Note: untyped (i.e. caller has to cast) because it is used for different kinds of handlers, with unrelated types.
-
_typeHandler
Optional handler that can be attached to indicate how to handle additional type metadata associated with this type.Note: untyped (i.e. caller has to cast) because it is used for different kinds of handlers, with unrelated types.
-
_asStatic
protected final boolean _asStaticWhether entities defined with this type should be handled using static typing (as opposed to dynamic runtime type) or not.
-
-
Constructor Details
-
JavaType
protected JavaType(Class<?> raw, int additionalHash, Object valueHandler, Object typeHandler, boolean asStatic) Main base constructor for sub-classes to use- Parameters:
raw- "Raw" (type-erased) class for this typeadditionalHash- Additional hash code to use, in addition to hash code of the class namevalueHandler- internal handler (serializer/deserializer) to apply for this typetypeHandler- internal type handler (type serializer/deserializer) to apply for this typeasStatic- Whether this type declaration will force specific type as opposed to being a base type (usually for serialization typing)
-
JavaType
Copy-constructor used when refining/upgrading type instances.
-
-
Method Details
-
withContentType
Mutant factory method that may be called on structured types that have a so-called content type (element of arrays, value type of Maps, referenced type of referential types), and will construct a new instance that is identical to this instance, except that it has specified content type, instead of current one. If content type is already set to given type,thisis returned. If type does not have a content type (which is the case withSimpleType),IllegalArgumentExceptionwill be thrown.- Returns:
- Newly created type instance
-
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. The main use case is to allow forcing of specific root value serialization type, and specifically in resolving serializers for contained types (element types for arrays, Collections and Maps). -
withTypeHandler
Internal method that should not be used by any code outside of jackson-databind: only used internally by databind. May be removed from Jackson 3.0.This mutant factory method will construct a new instance that is identical to this instance, except that it will have specified type handler assigned.
- Parameters:
h- Handler to pass to new instance created- Returns:
- Newly created type instance with same type information, specified handler
-
withContentTypeHandler
Internal method that should not be used by any code outside of jackson-databind: only used internally by databind. May be removed from Jackson 3.0.This mutant factory method will construct a new instance that is identical to this instance, except that it will have specified content type (element type for arrays, value type for Maps and so forth) handler assigned.
- Parameters:
h- Handler to pass to new instance created- Returns:
- Newly created type instance with same type information, specified handler
-
withValueHandler
Internal method that should not be used by any code outside of jackson-databind: only used internally by databind. May be removed from Jackson 3.0.This mutant factory method will construct a new instance that is identical to this instance, except that it will have specified value handler assigned.
- Parameters:
h- Handler to pass to new instance created- Returns:
- Newly created type instance with same type information, specified handler
-
withContentValueHandler
Internal method that should not be used by any code outside of jackson-databind: only used internally by databind. May be removed from Jackson 3.0.Mutant factory method that will construct a new instance that is identical to this instance, except that it will have specified content value handler assigned.
- Parameters:
h- Handler to pass to new instance created- Returns:
- Newly created type instance with same type information, specified handler
-
withHandlersFrom
Internal method that should not be used by any code outside of jackson-databind: only used internally by databind. May be removed from Jackson 3.0.Mutant factory method that will try to copy handlers that the specified source type instance had, if any; this must be done recursively where necessary (as content types may be structured).
-
refine
public abstract JavaType refine(Class<?> rawType, TypeBindings bindings, JavaType superClass, JavaType[] superInterfaces) Mutant factory method that will try to create and return a sub-type instance for known parameterized types; for other types will return `null` to indicate that no just refinement makes necessary sense, without trying to detect special status through implemented interfaces. -
getRawClass
- Specified by:
getRawClassin classResolvedType
-
hasRawClass
Method that can be used to check whether this type has specified Class as its type erasure. Put another way, returns true if instantiation of this Type is given (type-erased) Class.- Specified by:
hasRawClassin classResolvedType
-
hasContentType
public boolean hasContentType()Accessor that allows determining whethergetContentType()should return a non-null value (that is, there is a "content type") or not. True ifisContainerType()orResolvedType.isReferenceType()return true. -
isTypeOrSubTypeOf
-
isTypeOrSuperTypeOf
-
isAbstract
public boolean isAbstract()- Specified by:
isAbstractin classResolvedType
-
isConcrete
public boolean isConcrete()Convenience method for checking whether underlying Java type is a concrete class or not: abstract classes and interfaces are not.- Specified by:
isConcretein classResolvedType
-
isThrowable
public boolean isThrowable()- Specified by:
isThrowablein classResolvedType
-
isArrayType
public boolean isArrayType()- Specified by:
isArrayTypein classResolvedType
-
isEnumType
public final boolean isEnumType()Method that basically does equivalent of:Enum.class.isAssignableFrom(getRawClass())
that is, returntrueif the underlying type erased class isEnumor one its subtypes (Enum implementations).- Specified by:
isEnumTypein classResolvedType
-
isEnumImplType
public final boolean isEnumImplType()Similar toisEnumType()except does NOT returntrueforEnum(since that is not Enum implementation type). -
isRecordType
public final boolean isRecordType()- Since:
- 2.12
-
isIterationType
public boolean isIterationType()Method that returns true if this instance is of typeIterationType.- Returns:
- True if this type is considered "iteration type"
- Since:
- 2.16
-
isInterface
public final boolean isInterface()- Specified by:
isInterfacein classResolvedType
-
isPrimitive
public final boolean isPrimitive()- Specified by:
isPrimitivein classResolvedType
-
isFinal
public final boolean isFinal()- Specified by:
isFinalin classResolvedType
-
isContainerType
public abstract boolean isContainerType()- Specified by:
isContainerTypein classResolvedType- Returns:
- True if type represented is a container type; this includes array, Map and Collection types.
-
isCollectionLikeType
public boolean isCollectionLikeType()- Specified by:
isCollectionLikeTypein classResolvedType- Returns:
- True if type is either true
Collectiontype, or something similar (meaning it has at least one type parameter, which describes type of contents)
-
isMapLikeType
public boolean isMapLikeType()- Specified by:
isMapLikeTypein classResolvedType- Returns:
- True if type is either true
Maptype, or something similar (meaning it has at least two type parameter; first one describing key type, second value type)
-
isJavaLangObject
public final boolean isJavaLangObject()Convenience method, short-hand forgetRawClass() == Object.classand used to figure if we basically have "untyped" type object. -
useStaticType
public final boolean useStaticType()Accessor for checking whether handlers for dealing with values of this type should use static typing (as opposed to dynamic typing). Note that while value of 'true' does mean that static typing is to be used, value of 'false' may still be overridden by other settings. -
hasGenericTypes
public boolean hasGenericTypes()- Specified by:
hasGenericTypesin classResolvedType
-
getKeyType
- Specified by:
getKeyTypein classResolvedType
-
getContentType
- Specified by:
getContentTypein classResolvedType
-
getReferencedType
- Specified by:
getReferencedTypein classResolvedType
-
containedTypeCount
public abstract int containedTypeCount()- Specified by:
containedTypeCountin classResolvedType
-
containedType
- Specified by:
containedTypein classResolvedType
-
containedTypeOrUnknown
Convenience method that is functionally same as:JavaType t = containedType(index); if (t == null) { t = TypeFactory.unknownType(); }and typically used to eliminate need for null checks for common case where we just want to check if containedType is available first; and if not, use "unknown type" (which translates tojava.lang.Objectbasically). -
getBindings
-
findSuperType
Method that may be called to find representation of given type within type hierarchy of this type: either this type (if this type has given erased type), one of its supertypes that has the erased types, or null if target is neither this type or any of its supertypes. -
getSuperClass
Accessor for finding fully resolved parent class of this type, if it has one; null if not. -
getInterfaces
Accessor for finding fully resolved interfaces this type implements, if any; empty array if none. -
findTypeParameters
Method that may be used to find paramaterization this type has for given type-erased generic target type. -
getValueHandler
Internal accessor that should not be used by any code outside of jackson-databind: only used internally by databind. May be removed from Jackson 3.0.- Returns:
- Value handler associated with this type, if any.
-
getTypeHandler
Internal accessor that should not be used by any code outside of jackson-databind: only used internally by databind. May be removed from Jackson 3.0.- Returns:
- Type handler associated with this type, if any.
-
getContentValueHandler
Internal accessor that should not be used by any code outside of jackson-databind: only used internally by databind. May be removed from Jackson 3.0.- Returns:
- Content value handler associated with this type, if any.
-
getContentTypeHandler
Internal accessor that should not be used by any code outside of jackson-databind: only used internally by databind. May be removed from Jackson 3.0.- Returns:
- Content type handler associated with this type, if any.
-
hasValueHandler
public boolean hasValueHandler() -
hasHandlers
public boolean hasHandlers()Helper method that checks whether this type, or its (optional) key or content type hasgetValueHandler()orgetTypeHandler(); that is, are there any non-standard handlers associated with this type object. -
getGenericSignature
Method for accessing signature that contains generic type information, in form compatible with JVM 1.5 as per JLS. It is a superset ofgetErasedSignature(), in that generic information can be automatically removed if necessary (just remove outermost angle brackets along with content inside) -
getGenericSignature
- Parameters:
sb- StringBuilder to append signature to- Returns:
- StringBuilder that was passed in; returned to allow call chaining
-
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. -
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.- Parameters:
sb- StringBuilder to append signature to- Returns:
- StringBuilder that was passed in; returned to allow call chaining
-
toString
-
equals
-
hashCode
public int hashCode()
-