Class ReflectUtil
java.lang.Object
org.huiche.core.support.ReflectUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic Field[]getEntityFields(Class<?> clazz) 获取实体类的所有字段,顺序从顶层父类到当前类,每个类内按声明顺序。static Field[]getRecordFields(Class<?> clazz) 获取 record 的实例字段(即 record 组件),顺序为声明顺序。static booleanhasTypeVariable(Type type) 判断类型中是否包含未解析的类型变量static ParameterizedTypeparameterizedType(Class<?> rawType, Type... typeArgs) 合成一个ParameterizedTypestatic TyperesolveTypeArgument(Class<?> clazz, Class<?> targetType, int index) 解析类继承或实现关系中目标类型的实际泛型参数static GetterunreflectGetter(Field field) 创建Field的getter方法的MethodHandle(只是为了处理异常)unreflectInstantiator(Class<?> cls) 创建实例化提供者unreflectInstantiator(Class<?> cls, Field[] fields) 创建实例化方法(传入参数,返回实例)static SetterunreflectSetter(Field field) 创建Field的setter方法的MethodHandle(只是为了处理异常)
-
Method Details
-
getEntityFields
获取实体类的所有字段,顺序从顶层父类到当前类,每个类内按声明顺序。 排除 final 和 static 和 transient 字段final 实例字段无法写入,因此不参与映射(静默跳过);不可变实体请使用 record, 其 final 组件通过
getRecordFields(Class)保留并由规范构造器填充。- Parameters:
clazz- 目标类- Returns:
- 字段数组
-
getRecordFields
-
parameterizedType
合成一个ParameterizedType- Parameters:
rawType- 原始类型typeArgs- 泛型- Returns:
- 带泛型的类型
-
resolveTypeArgument
-
hasTypeVariable
判断类型中是否包含未解析的类型变量- Parameters:
type- 类型- Returns:
- 是否包含类型变量
-
unreflectGetter
-
unreflectInstantiator
-
unreflectInstantiator
-
unreflectSetter
-