T - the generic type of the upper bound.public class GenericTypeImpl<T> extends AbstractGenericType<T>
GenericType interface.| Modifier and Type | Class and Description |
|---|---|
protected static class |
GenericTypeImpl.ClassBounds
This inner class represents the bounds of a
GenericType. |
| Modifier and Type | Field and Description |
|---|---|
private Class<? extends T> |
assignmentClass |
private GenericType<?> |
componentType |
private GenericType<?> |
definingType |
private GenericType<?> |
keyType |
private Class<T> |
retrievalClass |
private Type |
type |
private Type[] |
typeArgs |
private GenericType<?>[] |
typesArguments |
NO_TYPES| Modifier | Constructor and Description |
|---|---|
|
GenericTypeImpl(Type type)
The constructor.
|
|
GenericTypeImpl(Type valueType,
GenericType<?> definingType)
The constructor.
|
protected |
GenericTypeImpl(Type valueType,
GenericType<?> definingType,
boolean init)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected GenericType<?> |
create(Type genericType)
This method creates the
GenericType that encapsulates the given type. |
protected AbstractGenericType<T> |
create(Type genericType,
GenericType<?> genericDefiningType)
This method creates a new instance of this class.
|
Class<?> |
getArrayClass(Class<?> componentClass)
|
Class<? extends T> |
getAssignmentClass()
This method gets the
Class to be used for assignment (as parameter) of a value of this GenericType. |
protected GenericTypeImpl.ClassBounds |
getClassBounds(Type currentType)
This method gets the most specific
Class available by the type-safe analyzation of the given generic
type. |
GenericType<?> |
getComponentType()
This method gets the component-type of this
GenericType if it represents an array,
Collection or Map. |
GenericType<?> |
getDefiningType()
This method gets the defining type.
|
GenericType<?> |
getKeyType()
This method gets the key-type of this
GenericType if it represents a Map. |
Class<T> |
getRetrievalClass()
This method gets the
Class to be used for retrieval (the return-type) of a value of this
GenericType. |
Type |
getType()
This method gets the
Type represented by this GenericType. |
GenericType<?> |
getTypeArgument(int index)
This method gets the type-argument at the given
index. |
int |
getTypeArgumentCount()
This method gets the number of
type-arguments . |
protected void |
init()
Initializes this class.
|
equals, getDeclarationIndex, getGenericDeclarations, hashCode, isAssignableFrom, isCollection, isMap, resolveTypeVariable, toString, toStringSimple, wrapclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetTypeNameprivate final GenericType<?> definingType
private final Type type
private final Type[] typeArgs
private final GenericType<?>[] typesArguments
private GenericType<?> componentType
private GenericType<?> keyType
public GenericTypeImpl(Type valueType, GenericType<?> definingType)
valueType - is the value-type.definingType - is the defining-type.protected GenericTypeImpl(Type valueType, GenericType<?> definingType, boolean init)
valueType - is the value-type.definingType - is the defining-type.init - - true if init() shall be called, false if you want to call it from
constructor of your sub-class.protected final void init()
protected GenericType<?> create(Type genericType)
AbstractGenericTypeGenericType that encapsulates the given type.create in class AbstractGenericType<T>genericType - is the Type to get as GenericType.GenericType.GenericTypeFactory.createGenericType(Type)protected AbstractGenericType<T> create(Type genericType, GenericType<?> genericDefiningType)
genericType - is the value-type.genericDefiningType - is the defining-type.GenericType instance.protected GenericTypeImpl.ClassBounds getClassBounds(Type currentType)
Class available by the type-safe analyzation of the given generic
type. Unlike getClassBounds(Type) this method resolves TypeVariable s with the proper type
they have been bound with. type |
owningType |
|
comment |
|---|---|---|---|
| E | List<Foo> |
Foo | E is a TypeVariable representing the generic return-type of the method List.get(int)
|
currentType - is the type to convert.type.public Class<?> getArrayClass(Class<?> componentClass)
componentClass - is the component type.array-class.public GenericType<?> getComponentType()
GenericTypeGenericType if it represents an array,
Collection or Map. | type | GenericType.getComponentType() |
|---|---|
| List<Map<String, Long>> | Map<String, Long> |
List |
Object |
Foo[] |
Foo |
| Foo<Bar>[] | Foo<Bar> |
| Foo<Bar> | null |
| Map<String, Long> | Long |
GenericType or null if this GenericType does NOT
represent an array, Collection or Map.public GenericType<?> getKeyType()
GenericTypeGenericType if it represents a Map. | type | GenericType.getComponentType() |
|---|---|
| List<Map<String, Long>> | null |
Map |
Object |
Foo[] |
null |
| Foo<K,V> | null |
| Map<String, Long> | String |
| HashMap<? extends Number, Long> | ? extends Number |
GenericType or null if this GenericType does NOT represent a
Map.public GenericType<?> getDefiningType()
getDefiningType in class AbstractGenericType<T>null if NOT available.public Class<? extends T> getAssignmentClass()
GenericTypeClass to be used for assignment (as parameter) of a value of this GenericType.
retrieval-class if this GenericType is a
WildcardType. lower-bound, the assignment-class is never
null. If there is no lower-bound, the
assignment-class is the same as the retrieval-class.
Therefore the assignment-class is always equal or more specific to the
retrieval-class. | Type | GenericType.getAssignmentClass() |
|---|---|
| <? super Integer> | Integer |
| <? extends CharSequence> | CharSequence |
String |
String |
Class that is the lower bound.public Class<T> getRetrievalClass()
GenericTypeClass to be used for retrieval (the return-type) of a value of this
GenericType. assignment-class if this GenericType is a
WildcardType. retrieval-class is the upper-bound, however for usability and simplicity only one bound is supported. | Type | GenericType.getAssignmentClass() |
|---|---|
| <? super Integer> | Object |
| <? extends CharSequence> | CharSequence |
String |
String |
Class that is the upper bound.public Type getType()
GenericTypeType represented by this GenericType.Class.getGenericSuperclass(),
Class.getGenericInterfaces(),
Method.getGenericReturnType(),
Method.getGenericParameterTypes(),
Field.getGenericType(),
Constructor.getGenericParameterTypes()public int getTypeArgumentCount()
GenericTypetype-arguments .public GenericType<?> getTypeArgument(int index)
GenericTypeindex. GenericType representing Map<String, List<Integer>> this method would return
String for an index of 0 and List<Integer> for an index of 1.index - is the position of the requested type-argument. It has to be in the range from 0 to
GenericType.getTypeArgumentCount() - 1.index.GenericType.getTypeArgumentCount(),
ParameterizedType.getActualTypeArguments()Copyright © 2001–2019 mmm-Team. All rights reserved.