类 ReflectUtils
java.lang.Object
com.dtflys.forest.utils.ReflectUtils
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static booleancanAnnotationUseForInterface(Class<?> annotationType) static booleancanAnnotationUseForMethod(Class<?> annotationType) static booleancanAnnotationUseForParam(Class<?> annotationType) static MapconvertObjectToMap(Object srcObj, ForestConfiguration configuration) static voidcopyAnnotationAttributes(Annotation source, Object target) getAttributesFromAnnotation(Annotation ann, boolean checkOverrideAttribute) 从注解对象中获取所有属性static Field[]获取类中所有的字段 (包括所有父类的)static TypegetGenericArgument(Type type) 获取第一个泛型参数类型static TypegetGenericArgument(Type type, int index) 根据下标获取单个泛型参数类型static Type[]getGenericTypeArguments(Type type) 获取所有泛型参数类型static Method[]getMethods(Class<?> clazz) 获取类中所有的方法 (包括所有父类的)static booleanisForestAnnotation(Annotation annotation) 判断是否为Forest注解static booleanisForestAnnotation(Class<?> annotationType) 判断是否为Forest注解static booleanisForestBaseAnnotation(Class<?> annotationType) 判断是否为Forest接口注解static booleanisForestMethodAnnotation(Annotation annotation) 判断是否为Forest方法注解static booleanisForestMethodAnnotation(Class<?> annotationType) 判断是否为Forest方法注解static booleanisForestParamAnnotation(Annotation annotation) 判断是否为Forest注解static booleanisForestParamAnnotation(Class<?> annotationType) 判断是否为Forest参数注解static booleanisPrimaryArrayType(Class<?> type) 是否为基本数组类型static booleanisPrimaryType(Class<?> type) 是否是Java基本类型static Class<?>转换为Class类型对象static ParameterizedTypetoParameterizedType(Type type) 转换为ParameterizedType类型对象static Type转换为Type接口实例
-
构造器详细资料
-
ReflectUtils
public ReflectUtils()
-
-
方法详细资料
-
toType
转换为Type接口实例 -
toClass
-
toParameterizedType
转换为ParameterizedType类型对象将普通的
Type类型对象转换为ParameterizedType类型对象通过
ParameterizedType对象可以获取泛型的类型参数- 参数:
type- 普通 Java Type 类型,Type接口实例- 返回:
- 带泛型参数的 Type 类型,
ParameterizedType接口实例
-
getGenericTypeArguments
获取所有泛型参数类型从一个带泛型的类型中获取其所有的泛型参数类型
-
getGenericArgument
根据下标获取单个泛型参数类型从一个带泛型的类型中获取其第 index 个泛型参数类型
-
getGenericArgument
获取第一个泛型参数类型从一个带泛型的类型中获取其第一个泛型参数类型
-
isPrimaryType
是否是Java基本类型- 参数:
type- Java类,Class类实例- 返回:
true:是基本类型,false:不是基本类型
-
isPrimaryArrayType
是否为基本数组类型- 参数:
type- Java类,Class类实例- 返回:
true:是基本数组类型,false:不是基本数组类型
-
getAttributesFromAnnotation
-
getAttributesFromAnnotation
public static Map<String,Object> getAttributesFromAnnotation(Annotation ann, boolean checkOverrideAttribute) 从注解对象中获取所有属性- 参数:
ann- 注解对象,Annotation接口实例checkOverrideAttribute- 是否检测属性重写- 返回:
- 注解对象中有属性
Map表对象,Key:属性名 Value:属性值
-
isForestAnnotation
判断是否为Forest注解- 参数:
annotation- 注解对象- 返回:
true: 是Forest注解;false: 不是Forest注解
-
isForestAnnotation
判断是否为Forest注解- 参数:
annotationType- 注解类- 返回:
true: 是Forest注解;false: 不是Forest注解
-
isForestBaseAnnotation
判断是否为Forest接口注解- 参数:
annotationType- 注解类- 返回:
true: 是Forest接口注解;false: 不是Forest接口注解
-
isForestMethodAnnotation
判断是否为Forest方法注解- 参数:
annotation- 注解对象- 返回:
true: 是Forest方法注解;false: 不是Forest方法注解
-
isForestMethodAnnotation
判断是否为Forest方法注解- 参数:
annotationType- 注解类- 返回:
true: 是Forest方法注解;false: 不是Forest方法注解
-
isForestParamAnnotation
判断是否为Forest注解- 参数:
annotation- 注解对象- 返回:
true: 是Forest参数注解;false: 不是Forest参数注解
-
isForestParamAnnotation
判断是否为Forest参数注解- 参数:
annotationType- 注解类- 返回:
true: 是Forest参数注解;false: 不是Forest参数注解
-
canAnnotationUseForInterface
-
canAnnotationUseForMethod
-
canAnnotationUseForParam
-
copyAnnotationAttributes
-
convertObjectToMap
-
getFields
获取类中所有的字段 (包括所有父类的)- 参数:
clazz- 类- 返回:
- 字段列表
- 从以下版本开始:
- 1.5.30
-
getMethods
获取类中所有的方法 (包括所有父类的)- 参数:
clazz- 类- 返回:
- 方法列表
-