Class TypeResolver
java.lang.Object
cloud.opencode.base.reflect.type.TypeResolver
Type Resolver
类型解析器
Resolves type variables in the context of a specific type, enabling proper generic type inference.
在特定类型上下文中解析类型变量,实现正确的泛型类型推断。
Features | 主要功能:
- Type variable resolution - 类型变量解析
- Parameterized type resolution - 参数化类型解析
- Inheritance chain traversal - 继承链遍历
Usage Examples | 使用示例:
// Resolve type variable in context
Type resolved = TypeResolver.resolveType(StringList.class, listElementType);
// Get type variable map
Map<TypeVariable<?>, Type> typeMap = TypeResolver.getTypeVariableMap(StringList.class);
Security | 安全性:
- Thread-safe: Yes (stateless utility class) - 线程安全: 是(无状态工具类)
- Null-safe: No (caller must ensure non-null type arguments) - 空值安全: 否(调用方须确保非空类型参数)
- Since:
- JDK 25, opencode-base-reflect V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic TypefindTypeArgument(Type type, Class<?> targetType, int index) Finds the type argument for a specific type variable in the inheritance chain 在继承链中查找特定类型变量的类型参数static TypegetTypeArgument(Type type, int index) Gets the type argument at a specific index from a parameterized type 从参数化类型获取指定索引的类型参数static Map<TypeVariable<?>, Type> getTypeVariableMap(Type type) Gets the type variable map for a type 获取类型的类型变量映射static TyperesolveFieldType(Type context, Field field) Resolves the type of a field in a specific type context 在特定类型上下文中解析字段类型static Type[]resolveParameterTypes(Type context, Method method) Resolves the parameter types of a method in a specific type context 在特定类型上下文中解析方法参数类型static TyperesolveReturnType(Type context, Method method) Resolves the return type of a method in a specific type context 在特定类型上下文中解析方法返回类型static TyperesolveType(Type context, Type toResolve) Resolves a type in the context of another type 在另一类型上下文中解析类型
-
Method Details
-
resolveType
-
getTypeVariableMap
Gets the type variable map for a type 获取类型的类型变量映射- Parameters:
type- the type | 类型- Returns:
- map of type variables to their actual types | 类型变量到实际类型的映射
-
resolveReturnType
-
resolveParameterTypes
-
resolveFieldType
-
getTypeArgument
-
findTypeArgument
Finds the type argument for a specific type variable in the inheritance chain 在继承链中查找特定类型变量的类型参数- Parameters:
type- the type to search | 要搜索的类型targetType- the target parameterized type | 目标参数化类型index- the type argument index | 类型参数索引- Returns:
- the resolved type argument or null | 解析后的类型参数或null
-