public class ResolvableType
extends java.lang.Object
implements java.io.Serializable
Type
, providing access to
supertypes
, interfaces
, and
generic parameters
along with the ability to ultimately
resolve
to a Class
.
ResolvableTypes
may be obtained from fields
,
method parameters
,
method returns
or
classes
. Most methods on this class will themselves return
ResolvableType
s, allowing easy navigation. For example:
private HashMap<Integer, List<String>> myMap; public void example() { ResolvableType t = ResolvableType.forField(getClass().getDeclaredField("myMap")); t.getSuperType(); // AbstractMap<Integer, List<String>> t.asMap(); // Map<Integer, List<String>> t.getGeneric(0).resolve(); // Integer t.getGeneric(1).resolve(); // List t.getGeneric(1); // List<String> t.resolveGeneric(1, 0); // String }
forField(Field)
,
forMethodParameter(Method, int)
,
forMethodReturnType(Method)
,
forConstructorParameter(Constructor, int)
,
forClass(Class)
,
forType(Type)
,
forInstance(Object)
,
ResolvableTypeProvider
,
Serialized FormModifier and Type | Class and Description |
---|---|
private class |
ResolvableType.DefaultVariableResolver |
private static class |
ResolvableType.SyntheticParameterizedType |
private static class |
ResolvableType.TypeVariablesVariableResolver |
(package private) static interface |
ResolvableType.VariableResolver
Strategy interface used to resolve
TypeVariable s. |
private static class |
ResolvableType.WildcardBounds
Internal helper to handle bounds from
WildcardType s. |
Modifier and Type | Field and Description |
---|---|
private static ConcurrentReferenceHashMap<ResolvableType,ResolvableType> |
cache |
private ResolvableType |
componentType
The component type for an array or
null if the type should be deduced. |
private static ResolvableType[] |
EMPTY_TYPES_ARRAY |
private ResolvableType[] |
generics |
private java.lang.Integer |
hash |
private ResolvableType[] |
interfaces |
static ResolvableType |
NONE
ResolvableType returned when no value is available. |
private java.lang.Class<?> |
resolved
Copy of the resolved value.
|
private ResolvableType |
superType |
private java.lang.reflect.Type |
type
The underlying Java type being managed (only ever
null for NONE ). |
private SerializableTypeWrapper.TypeProvider |
typeProvider
Optional provider for the type.
|
private ResolvableType.VariableResolver |
variableResolver
The
VariableResolver to use or null if no resolver is available. |
Modifier | Constructor and Description |
---|---|
private |
ResolvableType(java.lang.Class<?> clazz)
Private constructor used to create a new
ResolvableType on a Class basis. |
private |
ResolvableType(java.lang.reflect.Type type,
SerializableTypeWrapper.TypeProvider typeProvider,
ResolvableType.VariableResolver variableResolver)
Private constructor used to create a new
ResolvableType for cache key purposes,
with no upfront resolution. |
private |
ResolvableType(java.lang.reflect.Type type,
SerializableTypeWrapper.TypeProvider typeProvider,
ResolvableType.VariableResolver variableResolver,
java.lang.Integer hash)
Private constructor used to create a new
ResolvableType for cache value purposes,
with upfront resolution and a pre-calculated hash. |
private |
ResolvableType(java.lang.reflect.Type type,
SerializableTypeWrapper.TypeProvider typeProvider,
ResolvableType.VariableResolver variableResolver,
ResolvableType componentType)
Private constructor used to create a new
ResolvableType for uncached purposes,
with upfront resolution but lazily calculated hash. |
Modifier and Type | Method and Description |
---|---|
ResolvableType |
as(java.lang.Class<?> type)
Return this type as a
ResolvableType of the specified class. |
ResolvableType |
asCollection()
Convenience method to return this type as a resolvable
Collection type. |
ResolvableType |
asMap()
Convenience method to return this type as a resolvable
Map type. |
(package private) ResolvableType.VariableResolver |
asVariableResolver()
Adapts this
ResolvableType to a ResolvableType.VariableResolver . |
private int |
calculateHashCode() |
static void |
clearCache()
Clear the internal
ResolvableType cache. |
boolean |
equals(java.lang.Object other) |
static ResolvableType |
forArrayComponent(ResolvableType componentType)
Return a
ResolvableType as a array of the specified componentType . |
static ResolvableType |
forClass(java.lang.Class<?> clazz)
Return a
ResolvableType for the specified Class ,
using the full generic type information for assignability checks. |
static ResolvableType |
forClass(java.lang.Class<?> baseType,
java.lang.Class<?> implementationClass)
Return a
ResolvableType for the specified base type
(interface or base class) with a given implementation class. |
static ResolvableType |
forClassWithGenerics(java.lang.Class<?> clazz,
java.lang.Class<?>... generics)
Return a
ResolvableType for the specified Class with pre-declared generics. |
static ResolvableType |
forClassWithGenerics(java.lang.Class<?> clazz,
ResolvableType... generics)
Return a
ResolvableType for the specified Class with pre-declared generics. |
static ResolvableType |
forConstructorParameter(java.lang.reflect.Constructor<?> constructor,
int parameterIndex)
Return a
ResolvableType for the specified Constructor parameter. |
static ResolvableType |
forConstructorParameter(java.lang.reflect.Constructor<?> constructor,
int parameterIndex,
java.lang.Class<?> implementationClass)
Return a
ResolvableType for the specified Constructor parameter
with a given implementation. |
static ResolvableType |
forField(java.lang.reflect.Field field)
Return a
ResolvableType for the specified Field . |
static ResolvableType |
forField(java.lang.reflect.Field field,
java.lang.Class<?> implementationClass)
Return a
ResolvableType for the specified Field with a given
implementation. |
static ResolvableType |
forField(java.lang.reflect.Field field,
int nestingLevel)
Return a
ResolvableType for the specified Field with the
given nesting level. |
static ResolvableType |
forField(java.lang.reflect.Field field,
int nestingLevel,
java.lang.Class<?> implementationClass)
Return a
ResolvableType for the specified Field with a given
implementation and the given nesting level. |
static ResolvableType |
forField(java.lang.reflect.Field field,
ResolvableType implementationType)
Return a
ResolvableType for the specified Field with a given
implementation. |
static ResolvableType |
forInstance(java.lang.Object instance)
Return a
ResolvableType for the specified instance. |
static ResolvableType |
forMethodParameter(java.lang.reflect.Method method,
int parameterIndex)
Return a
ResolvableType for the specified Method parameter. |
static ResolvableType |
forMethodParameter(java.lang.reflect.Method method,
int parameterIndex,
java.lang.Class<?> implementationClass)
Return a
ResolvableType for the specified Method parameter with a
given implementation. |
static ResolvableType |
forMethodParameter(MethodParameter methodParameter)
Return a
ResolvableType for the specified MethodParameter . |
static ResolvableType |
forMethodParameter(MethodParameter methodParameter,
ResolvableType implementationType)
Return a
ResolvableType for the specified MethodParameter with a
given implementation type. |
static ResolvableType |
forMethodParameter(MethodParameter methodParameter,
java.lang.reflect.Type targetType)
Return a
ResolvableType for the specified MethodParameter ,
overriding the target type to resolve with a specific given type. |
static ResolvableType |
forMethodReturnType(java.lang.reflect.Method method)
Return a
ResolvableType for the specified Method return type. |
static ResolvableType |
forMethodReturnType(java.lang.reflect.Method method,
java.lang.Class<?> implementationClass)
Return a
ResolvableType for the specified Method return type. |
static ResolvableType |
forRawClass(java.lang.Class<?> clazz)
Return a
ResolvableType for the specified Class , doing
assignability checks against the raw class only (analogous to
Class.isAssignableFrom(java.lang.Class<?>) , which this serves as a wrapper for. |
static ResolvableType |
forType(java.lang.reflect.Type type)
Return a
ResolvableType for the specified Type . |
(package private) static ResolvableType |
forType(java.lang.reflect.Type type,
ResolvableType.VariableResolver variableResolver)
|
static ResolvableType |
forType(java.lang.reflect.Type type,
ResolvableType owner)
Return a
ResolvableType for the specified Type backed by the given
owner type. |
(package private) static ResolvableType |
forType(java.lang.reflect.Type type,
SerializableTypeWrapper.TypeProvider typeProvider,
ResolvableType.VariableResolver variableResolver)
|
private static ResolvableType[] |
forTypes(java.lang.reflect.Type[] types,
ResolvableType.VariableResolver owner) |
ResolvableType |
getComponentType()
Return the ResolvableType representing the component type of the array or
NONE if this type does not represent an array. |
ResolvableType |
getGeneric(int... indexes)
Return a
ResolvableType representing the generic parameter for the given
indexes. |
ResolvableType[] |
getGenerics()
Return an array of
ResolvableType s representing the generic parameters of
this type. |
ResolvableType[] |
getInterfaces()
Return a
ResolvableType array representing the direct interfaces
implemented by this type. |
ResolvableType |
getNested(int nestingLevel)
Return a
ResolvableType for the specified nesting level. |
ResolvableType |
getNested(int nestingLevel,
java.util.Map<java.lang.Integer,java.lang.Integer> typeIndexesPerLevel)
Return a
ResolvableType for the specified nesting level. |
java.lang.Class<?> |
getRawClass()
Return the underlying Java
Class being managed, if available;
otherwise null . |
java.lang.Object |
getSource()
Return the underlying source of the resolvable type.
|
ResolvableType |
getSuperType()
Return a
ResolvableType representing the direct supertype of this type. |
java.lang.reflect.Type |
getType()
Return the underling Java
Type being managed. |
boolean |
hasGenerics()
Return
true if this type contains generic parameters. |
int |
hashCode() |
boolean |
hasUnresolvableGenerics()
Determine whether the underlying type has any unresolvable generics:
either through an unresolvable type variable on the type itself
or through implementing a generic interface in a raw fashion,
i.e.
|
boolean |
isArray()
Return
true if this type resolves to a Class that represents an array. |
boolean |
isAssignableFrom(java.lang.Class<?> other)
Determine whether this
ResolvableType is assignable from the
specified other type. |
boolean |
isAssignableFrom(ResolvableType other)
Determine whether this
ResolvableType is assignable from the
specified other type. |
private boolean |
isAssignableFrom(ResolvableType other,
java.util.Map<java.lang.reflect.Type,java.lang.reflect.Type> matchedBefore) |
(package private) boolean |
isEntirelyUnresolvable()
Return
true if this type contains unresolvable generics only,
that is, no substitute for any of its declared type variables. |
boolean |
isInstance(java.lang.Object obj)
Determine whether the given object is an instance of this
ResolvableType . |
private boolean |
isUnresolvableTypeVariable()
Determine whether the underlying type is a type variable that
cannot be resolved through the associated variable resolver.
|
private boolean |
isWildcardWithoutBounds()
Determine whether the underlying type represents a wildcard
without specific bounds (i.e., equal to
? extends Object ). |
private java.lang.Object |
readResolve()
Custom serialization support for
NONE . |
java.lang.Class<?> |
resolve()
Resolve this type to a
Class , returning null
if the type cannot be resolved. |
java.lang.Class<?> |
resolve(java.lang.Class<?> fallback)
Resolve this type to a
Class , returning the specified
fallback if the type cannot be resolved. |
private java.lang.reflect.Type |
resolveBounds(java.lang.reflect.Type[] bounds) |
private java.lang.Class<?> |
resolveClass() |
java.lang.Class<?> |
resolveGeneric(int... indexes)
|
java.lang.Class<?>[] |
resolveGenerics()
|
java.lang.Class<?>[] |
resolveGenerics(java.lang.Class<?> fallback)
|
(package private) static void |
resolveMethodParameter(MethodParameter methodParameter)
Resolve the top-level parameter type of the given
MethodParameter . |
(package private) ResolvableType |
resolveType()
Resolve this type by a single level, returning the resolved value or
NONE . |
private ResolvableType |
resolveVariable(java.lang.reflect.TypeVariable<?> variable) |
java.lang.String |
toString()
Return a String representation of this type in its fully resolved form
(including any generic parameters).
|
public static final ResolvableType NONE
ResolvableType
returned when no value is available. NONE
is used
in preference to null
so that multiple method calls can be safely chained.private static final ResolvableType[] EMPTY_TYPES_ARRAY
private static final ConcurrentReferenceHashMap<ResolvableType,ResolvableType> cache
private final java.lang.reflect.Type type
null
for NONE
).private final SerializableTypeWrapper.TypeProvider typeProvider
private final ResolvableType.VariableResolver variableResolver
VariableResolver
to use or null
if no resolver is available.private final ResolvableType componentType
null
if the type should be deduced.private final java.lang.Class<?> resolved
private final java.lang.Integer hash
private ResolvableType superType
private ResolvableType[] interfaces
private ResolvableType[] generics
private ResolvableType(java.lang.reflect.Type type, SerializableTypeWrapper.TypeProvider typeProvider, ResolvableType.VariableResolver variableResolver)
ResolvableType
for cache key purposes,
with no upfront resolution.private ResolvableType(java.lang.reflect.Type type, SerializableTypeWrapper.TypeProvider typeProvider, ResolvableType.VariableResolver variableResolver, java.lang.Integer hash)
ResolvableType
for cache value purposes,
with upfront resolution and a pre-calculated hash.private ResolvableType(java.lang.reflect.Type type, SerializableTypeWrapper.TypeProvider typeProvider, ResolvableType.VariableResolver variableResolver, ResolvableType componentType)
ResolvableType
for uncached purposes,
with upfront resolution but lazily calculated hash.private ResolvableType(java.lang.Class<?> clazz)
ResolvableType
on a Class
basis.
Avoids all instanceof
checks in order to create a straight Class
wrapper.public java.lang.reflect.Type getType()
Type
being managed. With the exception of
the NONE
constant, this method will never return null
.public java.lang.Class<?> getRawClass()
Class
being managed, if available;
otherwise null
.public java.lang.Object getSource()
Field
,
MethodParameter
or Type
depending on how the ResolvableType
was constructed. With the exception of the NONE
constant, this method will
never return null
. This method is primarily to provide access to additional
type information or meta-data that alternative JVM languages may provide.public boolean isInstance(java.lang.Object obj)
ResolvableType
.obj
- the object to checkisAssignableFrom(Class)
public boolean isAssignableFrom(java.lang.Class<?> other)
ResolvableType
is assignable from the
specified other type.other
- the type to be checked against (as a Class
)isAssignableFrom(ResolvableType)
public boolean isAssignableFrom(ResolvableType other)
ResolvableType
is assignable from the
specified other type.
Attempts to follow the same rules as the Java compiler, considering
whether both the resolved
Class
is
assignable from
the given type
as well as whether all generics
are assignable.
other
- the type to be checked against (as a ResolvableType
)true
if the specified other type can be assigned to this
ResolvableType
; false
otherwiseprivate boolean isAssignableFrom(ResolvableType other, java.util.Map<java.lang.reflect.Type,java.lang.reflect.Type> matchedBefore)
public boolean isArray()
true
if this type resolves to a Class that represents an array.getComponentType()
public ResolvableType getComponentType()
NONE
if this type does not represent an array.isArray()
public ResolvableType asCollection()
Collection
type.
Returns NONE
if this type does not implement or extend
Collection
.public ResolvableType asMap()
Map
type.
Returns NONE
if this type does not implement or extend
Map
.as(Class)
,
asCollection()
public ResolvableType as(java.lang.Class<?> type)
ResolvableType
of the specified class. Searches
supertype
and interface
hierarchies to find a match, returning NONE
if this type does not
implement or extend the specified class.type
- the required type (typically narrowed)ResolvableType
representing this object as the specified
type, or NONE
if not resolvable as that typeasCollection()
,
asMap()
,
getSuperType()
,
getInterfaces()
public ResolvableType getSuperType()
ResolvableType
representing the direct supertype of this type.
If no supertype is available this method returns NONE
.getInterfaces()
public ResolvableType[] getInterfaces()
ResolvableType
array representing the direct interfaces
implemented by this type. If this type does not implement any interfaces an
empty array is returned.getSuperType()
public boolean hasGenerics()
true
if this type contains generic parameters.getGeneric(int...)
,
getGenerics()
boolean isEntirelyUnresolvable()
true
if this type contains unresolvable generics only,
that is, no substitute for any of its declared type variables.public boolean hasUnresolvableGenerics()
true
only in those two scenarios.private boolean isUnresolvableTypeVariable()
private boolean isWildcardWithoutBounds()
? extends Object
).public ResolvableType getNested(int nestingLevel)
ResolvableType
for the specified nesting level. See
getNested(int, Map)
for details.nestingLevel
- the nesting levelResolvableType
type, or #NONE
public ResolvableType getNested(int nestingLevel, java.util.Map<java.lang.Integer,java.lang.Integer> typeIndexesPerLevel)
ResolvableType
for the specified nesting level. The nesting level
refers to the specific generic parameter that should be returned. A nesting level
of 1 indicates this type; 2 indicates the first nested generic; 3 the second; and so
on. For example, given List<Set<Integer>>
level 1 refers to the
List
, level 2 the Set
, and level 3 the Integer
.
The typeIndexesPerLevel
map can be used to reference a specific generic
for the given level. For example, an index of 0 would refer to a Map
key;
whereas, 1 would refer to the value. If the map does not contain a value for a
specific level the last generic will be used (e.g. a Map
value).
Nesting levels may also apply to array types; for example given
String[]
, a nesting level of 2 refers to String
.
If a type does not contain
generics the
supertype
hierarchy will be considered.
nestingLevel
- the required nesting level, indexed from 1 for the current
type, 2 for the first nested generic, 3 for the second and so ontypeIndexesPerLevel
- a map containing the generic index for a given nesting
level (may be null
)ResolvableType
for the nested level or NONE
public ResolvableType getGeneric(int... indexes)
ResolvableType
representing the generic parameter for the given
indexes. Indexes are zero based; for example given the type
Map<Integer, List<String>>
, getGeneric(0)
will access the
Integer
. Nested generics can be accessed by specifying multiple indexes;
for example getGeneric(1, 0)
will access the String
from the nested
List
. For convenience, if no indexes are specified the first generic is
returned.
If no generic is available at the specified indexes NONE
is returned.
indexes
- the indexes that refer to the generic parameter (may be omitted to
return the first generic)ResolvableType
for the specified generic or NONE
hasGenerics()
,
getGenerics()
,
resolveGeneric(int...)
,
resolveGenerics()
public ResolvableType[] getGenerics()
ResolvableType
s representing the generic parameters of
this type. If no generics are available an empty array is returned. If you need to
access a specific generic consider using the getGeneric(int...)
method as
it allows access to nested generics and protects against
IndexOutOfBoundsExceptions
.ResolvableType
s representing the generic parameters
(never null
)hasGenerics()
,
getGeneric(int...)
,
resolveGeneric(int...)
,
resolveGenerics()
public java.lang.Class<?>[] resolveGenerics()
null
, but it may contain null
elements})getGenerics()
,
resolve()
public java.lang.Class<?>[] resolveGenerics(java.lang.Class<?> fallback)
get
and resolve
generic parameters, using the specified fallback
if any type
cannot be resolved.fallback
- the fallback class to use if resolution fails (may be null
)null
, but it may contain null
elements})getGenerics()
,
resolve()
public java.lang.Class<?> resolveGeneric(int... indexes)
indexes
- the indexes that refer to the generic parameter
(may be omitted to return the first generic)Class
or null
getGeneric(int...)
,
resolve()
public java.lang.Class<?> resolve()
Class
, returning null
if the type cannot be resolved. This method will consider bounds of
TypeVariable
s and WildcardType
s if direct resolution fails;
however, bounds of Object.class
will be ignored.Class
, or null
if not resolvableresolve(Class)
,
resolveGeneric(int...)
,
resolveGenerics()
public java.lang.Class<?> resolve(java.lang.Class<?> fallback)
Class
, returning the specified
fallback
if the type cannot be resolved. This method will consider bounds
of TypeVariable
s and WildcardType
s if direct resolution fails;
however, bounds of Object.class
will be ignored.fallback
- the fallback class to use if resolution fails (may be null
)Class
or the fallback
resolve()
,
resolveGeneric(int...)
,
resolveGenerics()
private java.lang.Class<?> resolveClass()
ResolvableType resolveType()
NONE
.
Note: The returned ResolvableType
should only be used as an intermediary
as it cannot be serialized.
private java.lang.reflect.Type resolveBounds(java.lang.reflect.Type[] bounds)
private ResolvableType resolveVariable(java.lang.reflect.TypeVariable<?> variable)
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
private int calculateHashCode()
ResolvableType.VariableResolver asVariableResolver()
ResolvableType
to a ResolvableType.VariableResolver
.private java.lang.Object readResolve()
NONE
.public java.lang.String toString()
toString
in class java.lang.Object
public static ResolvableType forClass(java.lang.Class<?> clazz)
ResolvableType
for the specified Class
,
using the full generic type information for assignability checks.
For example: ResolvableType.forClass(MyArrayList.class)
.clazz
- the class to introspect (null
is semantically
equivalent to Object.class
for typical use cases here}ResolvableType
for the specified classforClass(Class, Class)
,
forClassWithGenerics(Class, Class...)
public static ResolvableType forRawClass(java.lang.Class<?> clazz)
ResolvableType
for the specified Class
, doing
assignability checks against the raw class only (analogous to
Class.isAssignableFrom(java.lang.Class<?>)
, which this serves as a wrapper for.
For example: ResolvableType.forRawClass(List.class)
.clazz
- the class to introspect (null
is semantically
equivalent to Object.class
for typical use cases here}ResolvableType
for the specified classforClass(Class)
,
getRawClass()
public static ResolvableType forClass(java.lang.Class<?> baseType, java.lang.Class<?> implementationClass)
ResolvableType
for the specified base type
(interface or base class) with a given implementation class.
For example: ResolvableType.forClass(List.class, MyArrayList.class)
.baseType
- the base type (must not be null
)implementationClass
- the implementation classResolvableType
for the specified base type backed by the
given implementation classforClass(Class)
,
forClassWithGenerics(Class, Class...)
public static ResolvableType forClassWithGenerics(java.lang.Class<?> clazz, java.lang.Class<?>... generics)
ResolvableType
for the specified Class
with pre-declared generics.clazz
- the class (or interface) to introspectgenerics
- the generics of the classResolvableType
for the specific class and genericsforClassWithGenerics(Class, ResolvableType...)
public static ResolvableType forClassWithGenerics(java.lang.Class<?> clazz, ResolvableType... generics)
ResolvableType
for the specified Class
with pre-declared generics.clazz
- the class (or interface) to introspectgenerics
- the generics of the classResolvableType
for the specific class and genericsforClassWithGenerics(Class, Class...)
public static ResolvableType forInstance(java.lang.Object instance)
ResolvableType
for the specified instance. The instance does not
convey generic information but if it implements ResolvableTypeProvider
a
more precise ResolvableType
can be used than the simple one based on
the Class instance
.instance
- the instanceResolvableType
for the specified instanceResolvableTypeProvider
public static ResolvableType forField(java.lang.reflect.Field field)
ResolvableType
for the specified Field
.field
- the source fieldResolvableType
for the specified fieldforField(Field, Class)
public static ResolvableType forField(java.lang.reflect.Field field, java.lang.Class<?> implementationClass)
ResolvableType
for the specified Field
with a given
implementation.
Use this variant when the class that declares the field includes generic parameter variables that are satisfied by the implementation class.
field
- the source fieldimplementationClass
- the implementation classResolvableType
for the specified fieldforField(Field)
public static ResolvableType forField(java.lang.reflect.Field field, ResolvableType implementationType)
ResolvableType
for the specified Field
with a given
implementation.
Use this variant when the class that declares the field includes generic parameter variables that are satisfied by the implementation type.
field
- the source fieldimplementationType
- the implementation typeResolvableType
for the specified fieldforField(Field)
public static ResolvableType forField(java.lang.reflect.Field field, int nestingLevel)
ResolvableType
for the specified Field
with the
given nesting level.field
- the source fieldnestingLevel
- the nesting level (1 for the outer level; 2 for a nested
generic type; etc)forField(Field)
public static ResolvableType forField(java.lang.reflect.Field field, int nestingLevel, java.lang.Class<?> implementationClass)
ResolvableType
for the specified Field
with a given
implementation and the given nesting level.
Use this variant when the class that declares the field includes generic parameter variables that are satisfied by the implementation class.
field
- the source fieldnestingLevel
- the nesting level (1 for the outer level; 2 for a nested
generic type; etc)implementationClass
- the implementation classResolvableType
for the specified fieldforField(Field)
public static ResolvableType forConstructorParameter(java.lang.reflect.Constructor<?> constructor, int parameterIndex)
ResolvableType
for the specified Constructor
parameter.constructor
- the source constructor (must not be null
)parameterIndex
- the parameter indexResolvableType
for the specified constructor parameterforConstructorParameter(Constructor, int, Class)
public static ResolvableType forConstructorParameter(java.lang.reflect.Constructor<?> constructor, int parameterIndex, java.lang.Class<?> implementationClass)
ResolvableType
for the specified Constructor
parameter
with a given implementation. Use this variant when the class that declares the
constructor includes generic parameter variables that are satisfied by the
implementation class.constructor
- the source constructor (must not be null
)parameterIndex
- the parameter indeximplementationClass
- the implementation classResolvableType
for the specified constructor parameterforConstructorParameter(Constructor, int)
public static ResolvableType forMethodReturnType(java.lang.reflect.Method method)
ResolvableType
for the specified Method
return type.method
- the source for the method return typeResolvableType
for the specified method returnforMethodReturnType(Method, Class)
public static ResolvableType forMethodReturnType(java.lang.reflect.Method method, java.lang.Class<?> implementationClass)
ResolvableType
for the specified Method
return type.
Use this variant when the class that declares the method includes generic
parameter variables that are satisfied by the implementation class.method
- the source for the method return typeimplementationClass
- the implementation classResolvableType
for the specified method returnforMethodReturnType(Method)
public static ResolvableType forMethodParameter(java.lang.reflect.Method method, int parameterIndex)
ResolvableType
for the specified Method
parameter.method
- the source method (must not be null
)parameterIndex
- the parameter indexResolvableType
for the specified method parameterforMethodParameter(Method, int, Class)
,
forMethodParameter(MethodParameter)
public static ResolvableType forMethodParameter(java.lang.reflect.Method method, int parameterIndex, java.lang.Class<?> implementationClass)
ResolvableType
for the specified Method
parameter with a
given implementation. Use this variant when the class that declares the method
includes generic parameter variables that are satisfied by the implementation class.method
- the source method (must not be null
)parameterIndex
- the parameter indeximplementationClass
- the implementation classResolvableType
for the specified method parameterforMethodParameter(Method, int, Class)
,
forMethodParameter(MethodParameter)
public static ResolvableType forMethodParameter(MethodParameter methodParameter)
ResolvableType
for the specified MethodParameter
.methodParameter
- the source method parameter (must not be null
)ResolvableType
for the specified method parameterforMethodParameter(Method, int)
public static ResolvableType forMethodParameter(MethodParameter methodParameter, ResolvableType implementationType)
ResolvableType
for the specified MethodParameter
with a
given implementation type. Use this variant when the class that declares the method
includes generic parameter variables that are satisfied by the implementation type.methodParameter
- the source method parameter (must not be null
)implementationType
- the implementation typeResolvableType
for the specified method parameterforMethodParameter(MethodParameter)
public static ResolvableType forMethodParameter(MethodParameter methodParameter, java.lang.reflect.Type targetType)
ResolvableType
for the specified MethodParameter
,
overriding the target type to resolve with a specific given type.methodParameter
- the source method parameter (must not be null
)targetType
- the type to resolve (a part of the method parameter's type)ResolvableType
for the specified method parameterforMethodParameter(Method, int)
static void resolveMethodParameter(MethodParameter methodParameter)
MethodParameter
.methodParameter
- the method parameter to resolveMethodParameter.setParameterType(java.lang.Class<?>)
public static ResolvableType forArrayComponent(ResolvableType componentType)
ResolvableType
as a array of the specified componentType
.componentType
- the component typeResolvableType
as an array of the specified component typeprivate static ResolvableType[] forTypes(java.lang.reflect.Type[] types, ResolvableType.VariableResolver owner)
public static ResolvableType forType(java.lang.reflect.Type type)
ResolvableType
for the specified Type
.
Note: The resulting ResolvableType
may not be Serializable
.type
- the source type or null
ResolvableType
for the specified Type
forType(Type, ResolvableType)
public static ResolvableType forType(java.lang.reflect.Type type, ResolvableType owner)
ResolvableType
for the specified Type
backed by the given
owner type. Note: The resulting ResolvableType
may not be Serializable
.type
- the source type or null
owner
- the owner type used to resolve variablesResolvableType
for the specified Type
and ownerforType(Type)
static ResolvableType forType(java.lang.reflect.Type type, ResolvableType.VariableResolver variableResolver)
type
- the source type or null
variableResolver
- the variable resolver or null
ResolvableType
for the specified Type
and ResolvableType.VariableResolver
static ResolvableType forType(java.lang.reflect.Type type, SerializableTypeWrapper.TypeProvider typeProvider, ResolvableType.VariableResolver variableResolver)
type
- the source type or null
typeProvider
- the type provider or null
variableResolver
- the variable resolver or null
ResolvableType
for the specified Type
and ResolvableType.VariableResolver
public static void clearCache()
ResolvableType
cache.