public abstract class GenericCollectionTypeResolver
extends java.lang.Object
Mainly intended for usage within the framework, determining the target type of values to be added to a collection or map (to be able to attempt type conversion if appropriate).
Constructor and Description |
---|
GenericCollectionTypeResolver() |
Modifier and Type | Method and Description |
---|---|
private static java.lang.Class<?> |
extractType(java.lang.reflect.Type type,
java.lang.Class<?> source,
int typeIndex,
java.util.Map<java.lang.reflect.TypeVariable,java.lang.reflect.Type> typeVariableMap,
java.util.Map<java.lang.Integer,java.lang.Integer> typeIndexesPerLevel,
int nestingLevel,
int currentLevel)
Extract the generic type from the given Type object.
|
private static java.lang.Class<?> |
extractTypeFromClass(java.lang.Class<?> clazz,
java.lang.Class<?> source,
int typeIndex)
Extract the generic type from the given Class object.
|
private static java.lang.Class<?> |
extractTypeFromClass(java.lang.Class<?> clazz,
java.lang.Class<?> source,
int typeIndex,
java.util.Map<java.lang.reflect.TypeVariable,java.lang.reflect.Type> typeVariableMap,
java.util.Map<java.lang.Integer,java.lang.Integer> typeIndexesPerLevel,
int nestingLevel,
int currentLevel)
Extract the generic type from the given Class object.
|
private static java.lang.Class<?> |
extractTypeFromParameterizedType(java.lang.reflect.ParameterizedType ptype,
java.lang.Class<?> source,
int typeIndex,
java.util.Map<java.lang.reflect.TypeVariable,java.lang.reflect.Type> typeVariableMap,
java.util.Map<java.lang.Integer,java.lang.Integer> typeIndexesPerLevel,
int nestingLevel,
int currentLevel)
Extract the generic type from the given ParameterizedType object.
|
static java.lang.Class<?> |
getCollectionFieldType(java.lang.reflect.Field collectionField)
Determine the generic element type of the given Collection field.
|
static java.lang.Class<?> |
getCollectionFieldType(java.lang.reflect.Field collectionField,
int nestingLevel)
Determine the generic element type of the given Collection field.
|
static java.lang.Class<?> |
getCollectionFieldType(java.lang.reflect.Field collectionField,
int nestingLevel,
java.util.Map<java.lang.Integer,java.lang.Integer> typeIndexesPerLevel)
Determine the generic element type of the given Collection field.
|
static java.lang.Class<?> |
getCollectionParameterType(MethodParameter methodParam)
Determine the generic element type of the given Collection parameter.
|
static java.lang.Class<?> |
getCollectionReturnType(java.lang.reflect.Method method)
Determine the generic element type of the given Collection return type.
|
static java.lang.Class<?> |
getCollectionReturnType(java.lang.reflect.Method method,
int nestingLevel)
Determine the generic element type of the given Collection return type.
|
static java.lang.Class<?> |
getCollectionType(java.lang.Class<? extends java.util.Collection> collectionClass)
Determine the generic element type of the given Collection class
(if it declares one through a generic superclass or generic interface).
|
private static java.lang.Class<?> |
getGenericFieldType(java.lang.reflect.Field field,
java.lang.Class<?> source,
int typeIndex,
java.util.Map<java.lang.Integer,java.lang.Integer> typeIndexesPerLevel,
int nestingLevel)
Extract the generic type from the given field.
|
private static java.lang.Class<?> |
getGenericParameterType(MethodParameter methodParam,
java.lang.Class<?> source,
int typeIndex)
Extract the generic parameter type from the given method or constructor.
|
private static java.lang.Class<?> |
getGenericReturnType(java.lang.reflect.Method method,
java.lang.Class<?> source,
int typeIndex,
int nestingLevel)
Extract the generic return type from the given method.
|
static java.lang.Class<?> |
getMapKeyFieldType(java.lang.reflect.Field mapField)
Determine the generic key type of the given Map field.
|
static java.lang.Class<?> |
getMapKeyFieldType(java.lang.reflect.Field mapField,
int nestingLevel)
Determine the generic key type of the given Map field.
|
static java.lang.Class<?> |
getMapKeyFieldType(java.lang.reflect.Field mapField,
int nestingLevel,
java.util.Map<java.lang.Integer,java.lang.Integer> typeIndexesPerLevel)
Determine the generic key type of the given Map field.
|
static java.lang.Class<?> |
getMapKeyParameterType(MethodParameter methodParam)
Determine the generic key type of the given Map parameter.
|
static java.lang.Class<?> |
getMapKeyReturnType(java.lang.reflect.Method method)
Determine the generic key type of the given Map return type.
|
static java.lang.Class<?> |
getMapKeyReturnType(java.lang.reflect.Method method,
int nestingLevel)
Determine the generic key type of the given Map return type.
|
static java.lang.Class<?> |
getMapKeyType(java.lang.Class<? extends java.util.Map> mapClass)
Determine the generic key type of the given Map class
(if it declares one through a generic superclass or generic interface).
|
static java.lang.Class<?> |
getMapValueFieldType(java.lang.reflect.Field mapField)
Determine the generic value type of the given Map field.
|
static java.lang.Class<?> |
getMapValueFieldType(java.lang.reflect.Field mapField,
int nestingLevel)
Determine the generic value type of the given Map field.
|
static java.lang.Class<?> |
getMapValueFieldType(java.lang.reflect.Field mapField,
int nestingLevel,
java.util.Map<java.lang.Integer,java.lang.Integer> typeIndexesPerLevel)
Determine the generic value type of the given Map field.
|
static java.lang.Class<?> |
getMapValueParameterType(MethodParameter methodParam)
Determine the generic value type of the given Map parameter.
|
static java.lang.Class<?> |
getMapValueReturnType(java.lang.reflect.Method method)
Determine the generic value type of the given Map return type.
|
static java.lang.Class<?> |
getMapValueReturnType(java.lang.reflect.Method method,
int nestingLevel)
Determine the generic value type of the given Map return type.
|
static java.lang.Class<?> |
getMapValueType(java.lang.Class<? extends java.util.Map> mapClass)
Determine the generic value type of the given Map class
(if it declares one through a generic superclass or generic interface).
|
private static boolean |
isIntrospectionCandidate(java.lang.Class clazz)
Determine whether the given class is a potential candidate
that defines generic collection or map types.
|
public static java.lang.Class<?> getCollectionType(java.lang.Class<? extends java.util.Collection> collectionClass)
collectionClass
- the collection class to introspectnull
if nonepublic static java.lang.Class<?> getMapKeyType(java.lang.Class<? extends java.util.Map> mapClass)
mapClass
- the map class to introspectnull
if nonepublic static java.lang.Class<?> getMapValueType(java.lang.Class<? extends java.util.Map> mapClass)
mapClass
- the map class to introspectnull
if nonepublic static java.lang.Class<?> getCollectionFieldType(java.lang.reflect.Field collectionField)
collectionField
- the collection field to introspectnull
if nonepublic static java.lang.Class<?> getCollectionFieldType(java.lang.reflect.Field collectionField, int nestingLevel)
collectionField
- the collection field to introspectnestingLevel
- the nesting level of the target type
(typically 1; e.g. in case of a List of Lists, 1 would indicate the
nested List, whereas 2 would indicate the element of the nested List)null
if nonepublic static java.lang.Class<?> getCollectionFieldType(java.lang.reflect.Field collectionField, int nestingLevel, java.util.Map<java.lang.Integer,java.lang.Integer> typeIndexesPerLevel)
collectionField
- the collection field to introspectnestingLevel
- the nesting level of the target type
(typically 1; e.g. in case of a List of Lists, 1 would indicate the
nested List, whereas 2 would indicate the element of the nested List)typeIndexesPerLevel
- Map keyed by nesting level, with each value
expressing the type index for traversal at that levelnull
if nonepublic static java.lang.Class<?> getMapKeyFieldType(java.lang.reflect.Field mapField)
mapField
- the map field to introspectnull
if nonepublic static java.lang.Class<?> getMapKeyFieldType(java.lang.reflect.Field mapField, int nestingLevel)
mapField
- the map field to introspectnestingLevel
- the nesting level of the target type
(typically 1; e.g. in case of a List of Lists, 1 would indicate the
nested List, whereas 2 would indicate the element of the nested List)null
if nonepublic static java.lang.Class<?> getMapKeyFieldType(java.lang.reflect.Field mapField, int nestingLevel, java.util.Map<java.lang.Integer,java.lang.Integer> typeIndexesPerLevel)
mapField
- the map field to introspectnestingLevel
- the nesting level of the target type
(typically 1; e.g. in case of a List of Lists, 1 would indicate the
nested List, whereas 2 would indicate the element of the nested List)typeIndexesPerLevel
- Map keyed by nesting level, with each value
expressing the type index for traversal at that levelnull
if nonepublic static java.lang.Class<?> getMapValueFieldType(java.lang.reflect.Field mapField)
mapField
- the map field to introspectnull
if nonepublic static java.lang.Class<?> getMapValueFieldType(java.lang.reflect.Field mapField, int nestingLevel)
mapField
- the map field to introspectnestingLevel
- the nesting level of the target type
(typically 1; e.g. in case of a List of Lists, 1 would indicate the
nested List, whereas 2 would indicate the element of the nested List)null
if nonepublic static java.lang.Class<?> getMapValueFieldType(java.lang.reflect.Field mapField, int nestingLevel, java.util.Map<java.lang.Integer,java.lang.Integer> typeIndexesPerLevel)
mapField
- the map field to introspectnestingLevel
- the nesting level of the target type
(typically 1; e.g. in case of a List of Lists, 1 would indicate the
nested List, whereas 2 would indicate the element of the nested List)typeIndexesPerLevel
- Map keyed by nesting level, with each value
expressing the type index for traversal at that levelnull
if nonepublic static java.lang.Class<?> getCollectionParameterType(MethodParameter methodParam)
methodParam
- the method parameter specificationnull
if nonepublic static java.lang.Class<?> getMapKeyParameterType(MethodParameter methodParam)
methodParam
- the method parameter specificationnull
if nonepublic static java.lang.Class<?> getMapValueParameterType(MethodParameter methodParam)
methodParam
- the method parameter specificationnull
if nonepublic static java.lang.Class<?> getCollectionReturnType(java.lang.reflect.Method method)
method
- the method to check the return type fornull
if nonepublic static java.lang.Class<?> getCollectionReturnType(java.lang.reflect.Method method, int nestingLevel)
If the specified nesting level is higher than 1, the element type of a nested Collection/Map will be analyzed.
method
- the method to check the return type fornestingLevel
- the nesting level of the target type
(typically 1; e.g. in case of a List of Lists, 1 would indicate the
nested List, whereas 2 would indicate the element of the nested List)null
if nonepublic static java.lang.Class<?> getMapKeyReturnType(java.lang.reflect.Method method)
method
- the method to check the return type fornull
if nonepublic static java.lang.Class<?> getMapKeyReturnType(java.lang.reflect.Method method, int nestingLevel)
method
- the method to check the return type fornestingLevel
- the nesting level of the target type
(typically 1; e.g. in case of a List of Lists, 1 would indicate the
nested List, whereas 2 would indicate the element of the nested List)null
if nonepublic static java.lang.Class<?> getMapValueReturnType(java.lang.reflect.Method method)
method
- the method to check the return type fornull
if nonepublic static java.lang.Class<?> getMapValueReturnType(java.lang.reflect.Method method, int nestingLevel)
method
- the method to check the return type fornestingLevel
- the nesting level of the target type
(typically 1; e.g. in case of a List of Lists, 1 would indicate the
nested List, whereas 2 would indicate the element of the nested List)null
if noneprivate static java.lang.Class<?> getGenericParameterType(MethodParameter methodParam, java.lang.Class<?> source, int typeIndex)
methodParam
- the method parameter specificationsource
- the source class/interface defining the generic parameter typestypeIndex
- the index of the type (e.g. 0 for Collections,
0 for Map keys, 1 for Map values)null
if noneprivate static java.lang.Class<?> getGenericFieldType(java.lang.reflect.Field field, java.lang.Class<?> source, int typeIndex, java.util.Map<java.lang.Integer,java.lang.Integer> typeIndexesPerLevel, int nestingLevel)
field
- the field to check the type forsource
- the source class/interface defining the generic parameter typestypeIndex
- the index of the type (e.g. 0 for Collections,
0 for Map keys, 1 for Map values)nestingLevel
- the nesting level of the target typenull
if noneprivate static java.lang.Class<?> getGenericReturnType(java.lang.reflect.Method method, java.lang.Class<?> source, int typeIndex, int nestingLevel)
method
- the method to check the return type forsource
- the source class/interface defining the generic parameter typestypeIndex
- the index of the type (e.g. 0 for Collections,
0 for Map keys, 1 for Map values)nestingLevel
- the nesting level of the target typenull
if noneprivate static java.lang.Class<?> extractType(java.lang.reflect.Type type, java.lang.Class<?> source, int typeIndex, java.util.Map<java.lang.reflect.TypeVariable,java.lang.reflect.Type> typeVariableMap, java.util.Map<java.lang.Integer,java.lang.Integer> typeIndexesPerLevel, int nestingLevel, int currentLevel)
type
- the Type to checksource
- the source collection/map Class that we checktypeIndex
- the index of the actual type argumentnestingLevel
- the nesting level of the target typecurrentLevel
- the current nested levelnull
if noneprivate static java.lang.Class<?> extractTypeFromParameterizedType(java.lang.reflect.ParameterizedType ptype, java.lang.Class<?> source, int typeIndex, java.util.Map<java.lang.reflect.TypeVariable,java.lang.reflect.Type> typeVariableMap, java.util.Map<java.lang.Integer,java.lang.Integer> typeIndexesPerLevel, int nestingLevel, int currentLevel)
ptype
- the ParameterizedType to checksource
- the expected raw source type (can be null
)typeIndex
- the index of the actual type argumentnestingLevel
- the nesting level of the target typecurrentLevel
- the current nested levelnull
if noneprivate static java.lang.Class<?> extractTypeFromClass(java.lang.Class<?> clazz, java.lang.Class<?> source, int typeIndex)
clazz
- the Class to checksource
- the expected raw source type (can be null
)typeIndex
- the index of the actual type argumentnull
if noneprivate static java.lang.Class<?> extractTypeFromClass(java.lang.Class<?> clazz, java.lang.Class<?> source, int typeIndex, java.util.Map<java.lang.reflect.TypeVariable,java.lang.reflect.Type> typeVariableMap, java.util.Map<java.lang.Integer,java.lang.Integer> typeIndexesPerLevel, int nestingLevel, int currentLevel)
clazz
- the Class to checksource
- the expected raw source type (can be null
)typeIndex
- the index of the actual type argumentnestingLevel
- the nesting level of the target typecurrentLevel
- the current nested levelnull
if noneprivate static boolean isIntrospectionCandidate(java.lang.Class clazz)
clazz
- the class to check