Package org.codehaus.jackson.map.type
Class ArrayType
- java.lang.Object
-
- org.codehaus.jackson.type.JavaType
-
- org.codehaus.jackson.map.type.TypeBase
-
- org.codehaus.jackson.map.type.ArrayType
-
- All Implemented Interfaces:
JsonSerializable,JsonSerializableWithType
public final class ArrayType extends TypeBase
Array types represent Java arrays, both primitive and object valued. Further, Object-valued arrays can have element type of any other legalJavaType.
-
-
Field Summary
Fields Modifier and Type Field Description protected JavaType_componentTypeType of elements in the array.protected java.lang.Object_emptyArrayWe will also keep track of shareable instance of empty array, since it usually needs to be constructed any way; and because it is essentially immutable and thus can be shared.-
Fields inherited from class org.codehaus.jackson.type.JavaType
_class, _hashCode, _typeHandler, _valueHandler
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected JavaType_narrow(java.lang.Class<?> subclass)Handling of narrowing conversions for arrays is trickier: for now, it is not even allowed.protected java.lang.StringbuildCanonicalName()static ArrayTypeconstruct(JavaType componentType)Deprecated.Since 1.9, if you must directly instantiate, call method that takes handlersstatic ArrayTypeconstruct(JavaType componentType, java.lang.Object valueHandler, java.lang.Object typeHandler)JavaTypecontainedType(int index)Method for accessing definitions of contained ("child") types.intcontainedTypeCount()Method for checking how many contained types this type has.java.lang.StringcontainedTypeName(int index)Not sure what symbolic name is used internally, if any; let's follow naming of Collection types here.booleanequals(java.lang.Object o)JavaTypegetContentType()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)java.lang.StringBuildergetErasedSignature(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.StringBuildergetGenericSignature(java.lang.StringBuilder sb)booleanhasGenericTypes()Method that can be used to find out if the type directly declares generic parameters (for its direct super-class and/or super-interfaces).booleanisAbstract()For some odd reason, modifiers for array classes would claim they are abstract types.booleanisArrayType()booleanisConcrete()For some odd reason, modifiers for array classes would claim they are abstract types.booleanisContainerType()JavaTypenarrowContentsBy(java.lang.Class<?> contentClass)For array types, both main type and content type can be modified; but ultimately they are interchangeable.java.lang.StringtoString()JavaTypewidenContentsBy(java.lang.Class<?> contentClass)ArrayTypewithContentTypeHandler(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.ArrayTypewithContentValueHandler(java.lang.Object h)ArrayTypewithTypeHandler(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.ArrayTypewithValueHandler(java.lang.Object h)-
Methods inherited from class org.codehaus.jackson.map.type.TypeBase
_classSignature, getTypeHandler, getValueHandler, serialize, serializeWithType, toCanonical
-
Methods inherited from class org.codehaus.jackson.type.JavaType
_assertSubclass, _widen, forcedNarrowBy, getErasedSignature, getGenericSignature, getKeyType, getRawClass, hashCode, hasRawClass, isCollectionLikeType, isEnumType, isFinal, isInterface, isMapLikeType, isPrimitive, isThrowable, narrowBy, setValueHandler, widenBy
-
-
-
-
Field Detail
-
_componentType
protected final JavaType _componentType
Type of elements in the array.
-
_emptyArray
protected final java.lang.Object _emptyArray
We will also keep track of shareable instance of empty array, since it usually needs to be constructed any way; and because it is essentially immutable and thus can be shared.
-
-
Method Detail
-
construct
@Deprecated public static ArrayType construct(JavaType componentType)
Deprecated.Since 1.9, if you must directly instantiate, call method that takes handlers
-
construct
public static ArrayType construct(JavaType componentType, java.lang.Object valueHandler, java.lang.Object typeHandler)
-
withTypeHandler
public ArrayType withTypeHandler(java.lang.Object h)
Description copied from class:JavaType"Copy method" that will construct a new instance that is identical to this instance, except that it will have specified type handler assigned.- Specified by:
withTypeHandlerin classJavaType- Returns:
- Newly created type instance
-
withContentTypeHandler
public ArrayType withContentTypeHandler(java.lang.Object h)
Description copied from class:JavaType"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.- Specified by:
withContentTypeHandlerin classJavaType- Returns:
- Newly created type instance
-
withValueHandler
public ArrayType withValueHandler(java.lang.Object h)
- Overrides:
withValueHandlerin classJavaType
-
withContentValueHandler
public ArrayType withContentValueHandler(java.lang.Object h)
- Overrides:
withContentValueHandlerin classJavaType
-
buildCanonicalName
protected java.lang.String buildCanonicalName()
- Specified by:
buildCanonicalNamein classTypeBase
-
_narrow
protected JavaType _narrow(java.lang.Class<?> subclass)
Handling of narrowing conversions for arrays is trickier: for now, it is not even allowed.
-
narrowContentsBy
public JavaType narrowContentsBy(java.lang.Class<?> contentClass)
For array types, both main type and content type can be modified; but ultimately they are interchangeable.- Specified by:
narrowContentsByin classJavaType
-
widenContentsBy
public JavaType widenContentsBy(java.lang.Class<?> contentClass)
- Specified by:
widenContentsByin classJavaType
-
isArrayType
public boolean isArrayType()
- Overrides:
isArrayTypein classJavaType
-
isAbstract
public boolean isAbstract()
For some odd reason, modifiers for array classes would claim they are abstract types. Not so, at least for our purposes.- Overrides:
isAbstractin classJavaType
-
isConcrete
public boolean isConcrete()
For some odd reason, modifiers for array classes would claim they are abstract types. Not so, at least for our purposes.- Overrides:
isConcretein classJavaType
-
hasGenericTypes
public boolean hasGenericTypes()
Description copied from class:JavaTypeMethod that can be used to find out if the type directly declares generic parameters (for its direct super-class and/or super-interfaces).- Overrides:
hasGenericTypesin classJavaType
-
containedTypeName
public java.lang.String containedTypeName(int index)
Not sure what symbolic name is used internally, if any; let's follow naming of Collection types here. Should not really matter since array types have no super types.- Overrides:
containedTypeNamein classJavaType- Parameters:
index- Index of contained type to return- Returns:
- Contained type at index, or null if no such type exists (no exception thrown)
-
isContainerType
public boolean isContainerType()
- Specified by:
isContainerTypein classJavaType- Returns:
- True if type represented is a container type; this includes array, Map and Collection types.
-
getContentType
public JavaType getContentType()
Description copied from class:JavaTypeMethod 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)- Overrides:
getContentTypein classJavaType
-
containedTypeCount
public int containedTypeCount()
Description copied from class:JavaTypeMethod for checking how many contained types this type has. Contained types are usually generic types, so that generic Maps have 2 contained types.- Overrides:
containedTypeCountin classJavaType
-
containedType
public JavaType containedType(int index)
Description copied from class:JavaTypeMethod for accessing definitions of contained ("child") types.- Overrides:
containedTypein classJavaType- Parameters:
index- Index of contained type to return- Returns:
- Contained type at index, or null if no such type exists (no exception thrown)
-
getGenericSignature
public java.lang.StringBuilder getGenericSignature(java.lang.StringBuilder sb)
- Specified by:
getGenericSignaturein classTypeBase- Parameters:
sb- StringBuilder to append signature to- Returns:
- StringBuilder that was passed in; returned to allow call chaining
-
getErasedSignature
public java.lang.StringBuilder getErasedSignature(java.lang.StringBuilder sb)
Description copied from class:JavaTypeMethod 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.- Specified by:
getErasedSignaturein classTypeBase- Parameters:
sb- StringBuilder to append signature to- Returns:
- StringBuilder that was passed in; returned to allow call chaining
-
-