Class TypeVariableUtil
java.lang.Object
cloud.opencode.base.reflect.type.TypeVariableUtil
Type Variable Utility Class
类型变量工具类
Utility class for working with type variables in generics.
用于处理泛型中类型变量的工具类。
Features | 主要功能:
- Type variable lookup by name - 按名称查找类型变量
- Type variable bounds extraction - 类型变量边界提取
- Type parameter analysis - 类型参数分析
Usage Examples | 使用示例:
TypeVariable<?> tv = TypeVariableUtil.getTypeVariable(MyClass.class, "T");
Type[] bounds = TypeVariableUtil.getBounds(tv);
Security | 安全性:
- Thread-safe: Yes (stateless utility class) - 线程安全: 是(无状态工具类)
- Null-safe: No (caller must ensure non-null arguments) - 空值安全: 否(调用方须确保非空参数)
Performance | 性能特性:
- Time complexity: O(p) where p is the number of type parameters on the class - 时间复杂度: O(p),p为类上的类型参数数量
- Space complexity: O(1) - 空间复杂度: O(1)
- Since:
- JDK 25, opencode-base-reflect V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic Set<TypeVariable<?>> collectTypeVariables(Type type) Collects all type variables from a type 从类型收集所有类型变量static booleancontainsTypeVariable(Type type) Checks if a type contains type variables 检查类型是否包含类型变量static Type[]getBounds(TypeVariable<?> typeVariable) Gets the bounds of a type variable 获取类型变量的边界static Class<?> getRawUpperBound(TypeVariable<?> typeVariable) Gets the raw upper bound class of a type variable 获取类型变量的原始上界类getTypeArgumentsByName(Type type) Creates a map of type variable names to their Types from a parameterized type 从参数化类型创建类型变量名到Type的映射static TypeVariable<?> getTypeVariable(Class<?> clazz, String name) Gets type variable by name from a class 从类按名称获取类型变量getTypeVariableNames(Class<?> clazz) Gets all type variable names from a class 从类获取所有类型变量名static TypegetUpperBound(TypeVariable<?> typeVariable) Gets the upper bound of a type variable 获取类型变量的上界static booleanhasBounds(TypeVariable<?> typeVariable) Checks if a type variable has non-Object bounds 检查类型变量是否有非Object边界
-
Method Details
-
getTypeVariable
Gets type variable by name from a class 从类按名称获取类型变量- Parameters:
clazz- the class | 类name- the type variable name | 类型变量名- Returns:
- the type variable or null | 类型变量或null
-
getTypeVariableNames
-
getBounds
Gets the bounds of a type variable 获取类型变量的边界- Parameters:
typeVariable- the type variable | 类型变量- Returns:
- array of bounds | 边界数组
-
hasBounds
Checks if a type variable has non-Object bounds 检查类型变量是否有非Object边界- Parameters:
typeVariable- the type variable | 类型变量- Returns:
- true if has bounds | 如果有边界返回true
-
getUpperBound
Gets the upper bound of a type variable 获取类型变量的上界- Parameters:
typeVariable- the type variable | 类型变量- Returns:
- the upper bound or Object.class | 上界或Object.class
-
getRawUpperBound
Gets the raw upper bound class of a type variable 获取类型变量的原始上界类- Parameters:
typeVariable- the type variable | 类型变量- Returns:
- the raw upper bound class | 原始上界类
-
containsTypeVariable
Checks if a type contains type variables 检查类型是否包含类型变量- Parameters:
type- the type | 类型- Returns:
- true if contains type variables | 如果包含类型变量返回true
-
collectTypeVariables
Collects all type variables from a type 从类型收集所有类型变量- Parameters:
type- the type | 类型- Returns:
- set of type variables | 类型变量集合
-
getTypeArgumentsByName
-