public class MapLikeType extends TypeBase
Map
, but that do not have enough
introspection functionality to allow for some level of generic handling.
This specifically allows framework to check for configuration and annotation
settings used for Map types, and pass these to custom handlers that may be more
familiar with actual type.Modifier and Type | Field and Description |
---|---|
protected JavaType |
_keyType
Type of keys of Map.
|
protected JavaType |
_valueType
Type of values of Map.
|
_asStatic, _class, _hash, _typeHandler, _valueHandler
Modifier | Constructor and Description |
---|---|
protected |
MapLikeType(Class<?> mapType,
JavaType keyT,
JavaType valueT,
Object valueHandler,
Object typeHandler,
boolean asStatic) |
Modifier and Type | Method and Description |
---|---|
protected JavaType |
_narrow(Class<?> subclass) |
protected String |
buildCanonicalName() |
static MapLikeType |
construct(Class<?> rawType,
JavaType keyT,
JavaType valueT) |
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)
Not sure if we should count on this, but type names
for core interfaces are "K" and "V" respectively.
|
boolean |
equals(Object o) |
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)
|
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.
|
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<?> |
getParameterSource()
Accessor that can be used to find out type for which parameterization
is applied: this is often NOT same as what
ResolvedType.getRawClass() returns,
but rather one of it supertype. |
boolean |
isContainerType() |
boolean |
isMapLikeType() |
boolean |
isTrueMapType()
Method that can be used for checking whether this type is a
"real" Collection type; meaning whether it represents a parameterized
subtype of
Collection or just something that acts
like one. |
JavaType |
narrowContentsBy(Class<?> contentClass) |
JavaType |
narrowKey(Class<?> keySubclass) |
String |
toString() |
JavaType |
widenContentsBy(Class<?> contentClass) |
JavaType |
widenKey(Class<?> keySubclass) |
MapLikeType |
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.
|
MapLikeType |
withContentValueHandler(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.
|
MapLikeType |
withKeyTypeHandler(Object h) |
MapLikeType |
withKeyValueHandler(Object h) |
MapLikeType |
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.
|
MapLikeType |
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.
|
MapLikeType |
withValueHandler(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.
|
_classSignature, getTypeHandler, getValueHandler, serialize, serializeWithType, toCanonical
_assertSubclass, _widen, containedTypeOrUnknown, forcedNarrowBy, getErasedSignature, getGenericSignature, getRawClass, hasGenericTypes, hashCode, hasRawClass, isAbstract, isArrayType, isCollectionLikeType, isConcrete, isEnumType, isFinal, isInterface, isJavaLangObject, isPrimitive, isThrowable, narrowBy, useStaticType, widenBy
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getTypeName
protected final JavaType _keyType
protected final JavaType _valueType
public static MapLikeType construct(Class<?> rawType, JavaType keyT, JavaType valueT)
public JavaType narrowContentsBy(Class<?> contentClass)
narrowContentsBy
in class JavaType
public JavaType widenContentsBy(Class<?> contentClass)
widenContentsBy
in class JavaType
public MapLikeType withTypeHandler(Object h)
JavaType
withTypeHandler
in class JavaType
public MapLikeType withContentTypeHandler(Object h)
JavaType
withContentTypeHandler
in class JavaType
public MapLikeType withValueHandler(Object h)
JavaType
withValueHandler
in class JavaType
public MapLikeType withContentValueHandler(Object h)
JavaType
withContentValueHandler
in class JavaType
public MapLikeType withStaticTyping()
JavaType
withStaticTyping
in class JavaType
protected String buildCanonicalName()
buildCanonicalName
in class TypeBase
public boolean isContainerType()
isContainerType
in class JavaType
public boolean isMapLikeType()
isMapLikeType
in class JavaType
Map
type,
or something similar (meaning it has at least two type parameter;
first one describing key type, second value type)public JavaType getKeyType()
ResolvedType
getKeyType
in class JavaType
public JavaType getContentType()
ResolvedType
getContentType
in class JavaType
public int containedTypeCount()
ResolvedType
containedTypeCount
in class JavaType
public JavaType containedType(int index)
ResolvedType
containedType
in class JavaType
index
- Index of contained type to returnpublic String containedTypeName(int index)
containedTypeName
in class JavaType
index
- Index of contained type to returnpublic Class<?> getParameterSource()
ResolvedType
ResolvedType.getRawClass()
returns,
but rather one of it supertype.
For example: for type like HashMap
, raw type is
HashMap
; but this method would return
Map
, because relevant type parameters that are
resolved (and accessible using ResolvedType.containedType(int)
and
ResolvedType.getKeyType()
) are parameter for Map
(which may or may not be same as type parameters for subtype;
in case of HashMap
they are, but for further
subtypes they may be different parameters or possibly none at all).
getParameterSource
in class JavaType
public StringBuilder getErasedSignature(StringBuilder sb)
JavaType
getErasedSignature
in class TypeBase
sb
- StringBuilder to append signature topublic StringBuilder getGenericSignature(StringBuilder sb)
getGenericSignature
in class TypeBase
sb
- StringBuilder to append signature topublic MapLikeType withKeyTypeHandler(Object h)
public MapLikeType withKeyValueHandler(Object h)
public boolean isTrueMapType()
Collection
or just something that acts
like one.Copyright © 2016 JBoss by Red Hat. All rights reserved.