类 ReflectionUtils
java.lang.Object
com.github.aqiu202.util.ReflectionUtils
-
嵌套类概要
嵌套类修饰符和类型类说明static classstatic classstatic enum -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static <T extends Annotation>
TfindAnnotation(AnnotatedElement element, Class<T> annotationType) static <T extends Annotation>
List<T>findAnnotations(AnnotatedElement element, Class<T> annotationType) static StringgenerateKey(Class<?> type, String methodName, Class<?>... parameterTypes) static StringgenerateKey(String methodName, Class<?>... parameterTypes) static StringgenerateMethodKey(Method method) static ReflectionUtils.ClassFieldsgetAllField(Class<?> type) 获取所有的属性(包含私有属性,但不包含final和static修饰的属性)static ReflectionUtils.ClassFieldsgetAllField(Class<?> type, ReflectionUtils.ScanDirection direction) static ReflectionUtils.ClassMethodsgetAllMethod(Class<?> type) 获取所有的方法(包含私有方法,但不包含abstract和static修饰的方法)static ReflectionUtils.ClassMethodsgetAllMethod(Class<?> type, ReflectionUtils.ScanDirection direction) 获取所有的方法(包含私有方法,但不包含abstract和static修饰的方法)static <T extends Annotation>
TgetAnnotation(AnnotatedElement element, Class<T> annotationType) static <T extends Annotation>
List<T>getAnnotations(AnnotatedElement element, Class<T> annotationType) static ObjectgetComplexValue(Object target, String complexFieldName) 获取对象某个字段的值static ObjectgetComplexValue(Object target, String complexFieldName, String separator) 获取对象某个字段的值static Constructor<?>[]getConstructors(Class<?> type) static Constructor<?>[]getDeclaredConstructors(Class<?> type) static Constructor<?>getDefaultConstructor(Class<?> type) static Fieldstatic ReflectionUtils.ClassFields获取所有的属性(不包含私有属性)static Methodstatic StringgetMethodDescriptor(Method method) static ReflectionUtils.ClassMethodsgetMethods(Class<?> type) 获取所有的方法(不包含私有方法)static StringgetTypeDescriptor(Class<?> type) static Object获取对象某个字段的值static Object获取对象某个字段的值static Object获取对象某个字段的值static booleanhasAnnotation(AnnotatedElement element, Class<? extends Annotation> annotationType) static booleanhasAnnotation(AnnotatedElement element, Class<? extends Annotation>... annotationTypes) static booleanhasAnnotationPresent(AnnotatedElement element, Class<? extends Annotation>... annotationTypes) static ObjectinvokeMethod(Method method, Object instance, Object... args) static booleanisAnnotationPresent(AnnotatedElement element, Class<? extends Annotation> annotation) static voidmakeAccessible(Constructor<?> ctor) 使构造器可访问static voidmakeAccessible(Field field) 使字段可访问static voidmakeAccessible(Method method) 使方法可访问static ObjectnewInstance(Constructor<?> constructor, Object... args) static Object获取对象某个字段的值static Object给对象的某个字段赋值
-
构造器详细资料
-
ReflectionUtils
public ReflectionUtils()
-
-
方法详细资料
-
makeAccessible
使构造器可访问- 参数:
ctor- 构造器
-
makeAccessible
使方法可访问- 参数:
method- 方法
-
makeAccessible
使字段可访问- 参数:
field- 字段
-
newInstance
-
getAllMethod
获取所有的方法(包含私有方法,但不包含abstract和static修饰的方法)- 参数:
type- 类型- 返回:
- 所有方法集合
-
getAllMethod
public static ReflectionUtils.ClassMethods getAllMethod(@Nonnull Class<?> type, ReflectionUtils.ScanDirection direction) 获取所有的方法(包含私有方法,但不包含abstract和static修饰的方法)- 参数:
type- 类型direction- 扫描方向- 返回:
- 所有方法集合
-
getMethods
获取所有的方法(不包含私有方法)- 参数:
type- 类型- 返回:
- 所有方法集合
-
getMethod
-
invokeMethod
-
getAllField
获取所有的属性(包含私有属性,但不包含final和static修饰的属性)- 参数:
type- 类型- 返回:
- 所有属性集合
-
getAllField
public static ReflectionUtils.ClassFields getAllField(@Nonnull Class<?> type, ReflectionUtils.ScanDirection direction) -
getFields
获取所有的属性(不包含私有属性)- 参数:
type- 类型- 返回:
- 所有属性集合
-
getField
-
getDeclaredConstructors
-
getConstructors
-
getDefaultConstructor
-
getValue
获取对象某个字段的值- 参数:
target- 对象field- 字段- 返回:
- 字段值
-
getComplexValue
获取对象某个字段的值- 参数:
target- 对象complexFieldName- 字段名称 以点"."拼接- 返回:
- 字段值
-
getComplexValue
public static Object getComplexValue(@Nonnull Object target, String complexFieldName, String separator) 获取对象某个字段的值- 参数:
target- 对象complexFieldName- 字段名称separator- 字段分隔符- 返回:
- 字段值
-
getValue
获取对象某个字段的值- 参数:
target- 对象fieldNames- 字段名称数组- 返回:
- 字段值
-
getValue
获取对象某个字段的值- 参数:
target- 对象fieldName- 字段名称- 返回:
- 字段值
-
setValue
给对象的某个字段赋值- 参数:
target- 对象fieldName- 字段名称value- 字段值- 返回:
- 字段值
-
setValue
获取对象某个字段的值- 参数:
target- 对象field- 字段value- 字段值- 返回:
- 字段值
-
getAnnotation
public static <T extends Annotation> T getAnnotation(@Nonnull AnnotatedElement element, Class<T> annotationType) -
getAnnotations
public static <T extends Annotation> List<T> getAnnotations(@Nonnull AnnotatedElement element, Class<T> annotationType) -
findAnnotation
public static <T extends Annotation> T findAnnotation(@Nonnull AnnotatedElement element, Class<T> annotationType) -
findAnnotations
public static <T extends Annotation> List<T> findAnnotations(@Nonnull AnnotatedElement element, Class<T> annotationType) -
isAnnotationPresent
public static boolean isAnnotationPresent(@Nonnull AnnotatedElement element, Class<? extends Annotation> annotation) -
hasAnnotationPresent
public static boolean hasAnnotationPresent(@Nonnull AnnotatedElement element, Class<? extends Annotation>... annotationTypes) -
hasAnnotation
public static boolean hasAnnotation(@Nonnull AnnotatedElement element, Class<? extends Annotation>... annotationTypes) -
hasAnnotation
public static boolean hasAnnotation(@Nonnull AnnotatedElement element, Class<? extends Annotation> annotationType) -
generateMethodKey
-
generateKey
-
generateKey
-
getMethodDescriptor
-
getTypeDescriptor
-