类 GenericTypeResolver
java.lang.Object
cn.taketoday.core.GenericTypeResolver
Helper class for resolving generic types against type variables.
Mainly intended for usage within the framework, resolving method parameter types even when they are declared generically.
- 从以下版本开始:
- 3.0
- 作者:
- Juergen Hoeller, Rob Harrop, Sam Brannen, TODAY 2021/3/8 18:22
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明private static final ConcurrentHashMap<Class<?>,Map<TypeVariable, Type>> Cache from Class to TypeVariable Map. -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明private static voidbuildTypeVariableMap(ResolvableType type, Map<TypeVariable, Type> typeVariableMap) private static <T> Class<T>getSingleGeneric(ResolvableType resolvableType) static Map<TypeVariable,Type> getTypeVariableMap(Class<?> clazz) static Class<?>resolveReturnType(Method method, Class<?> clazz) Determine the target type for the generic return type of the given method, where formal type variables are declared on the given class.static Class<?>resolveReturnTypeArgument(Method method, Class<?> genericIfc) Resolve the single type argument of the given generic interface against the given target method which is assumed to return the given interface or an implementation of it.static TyperesolveType(Type genericType, Class<?> contextClass) Resolve the given generic type against the given context class, substituting type variables as far as possible.static Class<?>resolveType(Type genericType, Map<TypeVariable, Type> map) Resolve the specified generic type against the given TypeVariable map.static <T> Class<T>resolveTypeArgument(Class<?> clazz, Class<?> genericIfc) Resolve the single type argument of the given generic interface against the given target class which is assumed to implement the generic interface and possibly declare a concrete type for its type variable.static Class<?>[]resolveTypeArguments(Class<?> clazz, Class<?> genericIfc) Resolve the type arguments of the given generic interface against the given target class which is assumed to implement the generic interface and possibly declare concrete types for its type variables.private static ResolvableTyperesolveVariable(TypeVariable<?> typeVariable, ResolvableType contextType) private static ResolvableTyperesolveWildcard(WildcardType wildcardType, ResolvableType contextType)
-
字段详细资料
-
typeVariableCache
Cache from Class to TypeVariable Map.
-
-
构造器详细资料
-
GenericTypeResolver
public GenericTypeResolver()
-
-
方法详细资料
-
resolveReturnType
Determine the target type for the generic return type of the given method, where formal type variables are declared on the given class.- 参数:
method- the method to introspectclazz- the class to resolve type variables against- 返回:
- the corresponding generic parameter or return type
-
resolveReturnTypeArgument
Resolve the single type argument of the given generic interface against the given target method which is assumed to return the given interface or an implementation of it.- 参数:
method- the target method to check the return type ofgenericIfc- the generic interface or superclass to resolve the type argument from- 返回:
- the resolved parameter type of the method return type, or
nullif not resolvable or if the single argument is of typeWildcardType.
-
resolveTypeArgument
Resolve the single type argument of the given generic interface against the given target class which is assumed to implement the generic interface and possibly declare a concrete type for its type variable.- 参数:
clazz- the target class to check againstgenericIfc- the generic interface or superclass to resolve the type argument from- 返回:
- the resolved type of the argument, or
nullif not resolvable
-
getSingleGeneric
-
resolveTypeArguments
Resolve the type arguments of the given generic interface against the given target class which is assumed to implement the generic interface and possibly declare concrete types for its type variables.- 参数:
clazz- the target class to check againstgenericIfc- the generic interface or superclass to resolve the type argument from- 返回:
- the resolved type of each argument, with the array size matching the
number of actual type arguments, or
nullif not resolvable
-
resolveType
Resolve the given generic type against the given context class, substituting type variables as far as possible.- 参数:
genericType- the (potentially) generic typecontextClass- a context class for the target type, for example a class in which the target type appears in a method signature (can benull)- 返回:
- the resolved type (possibly the given generic type as-is)
-
resolveVariable
private static ResolvableType resolveVariable(TypeVariable<?> typeVariable, ResolvableType contextType) -
resolveWildcard
private static ResolvableType resolveWildcard(WildcardType wildcardType, ResolvableType contextType) -
resolveType
Resolve the specified generic type against the given TypeVariable map.- 参数:
genericType- the generic type to resolvemap- the TypeVariable Map to resolved against- 返回:
- the type if it resolves to a Class, or
Object.classotherwise
-
getTypeVariableMap
Build a mapping ofTypeVariable namestoconcrete classesfor the specifiedClass. Searches all super types, enclosing types and interfaces.- 另请参阅:
-
buildTypeVariableMap
private static void buildTypeVariableMap(ResolvableType type, Map<TypeVariable, Type> typeVariableMap)
-