public class ReflectUtil
extends org.springframework.util.ReflectionUtils
org.springframework.util.ReflectionUtils.FieldCallback, org.springframework.util.ReflectionUtils.FieldFilter, org.springframework.util.ReflectionUtils.MethodCallback, org.springframework.util.ReflectionUtils.MethodFilter| Constructor and Description |
|---|
ReflectUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <T extends Annotation> |
getAnnotation(Class<?> clazz,
String fieldName,
Class<T> annotationClass)
获取 所有 field 属性上的注解
|
static PropertyDescriptor[] |
getBeanGetters(Class type)
获取 Bean 的所有 get方法
|
static PropertyDescriptor[] |
getBeanSetters(Class type)
获取 Bean 的所有 set方法
|
static Field |
getField(Class<?> clazz,
String fieldName)
获取 类属性
|
static Object |
getField(Field field,
Object target)
重写 setField 的方法,用于处理 setAccessible 的问题
|
static Object |
getField(String fieldName,
Object target)
重写 setField 的方法,用于处理 setAccessible 的问题
|
static org.springframework.core.convert.Property |
getProperty(Class<?> propertyType,
PropertyDescriptor propertyDescriptor,
String propertyName)
获取 bean 的属性信息
|
static org.springframework.core.convert.Property |
getProperty(Class<?> propertyType,
String propertyName)
获取 bean 的属性信息
|
static PropertyDescriptor[] |
getPropertyDescriptors(Class type,
boolean read,
boolean write)
获取 Bean 的所有 PropertyDescriptor
|
static org.springframework.core.convert.TypeDescriptor |
getTypeDescriptor(Class<?> propertyType,
PropertyDescriptor propertyDescriptor,
String propertyName)
获取 类属性信息
|
static org.springframework.core.convert.TypeDescriptor |
getTypeDescriptor(Class<?> propertyType,
String propertyName)
获取 bean 的属性信息
|
static Object |
invokeMethod(Method method,
Object target)
重写 invokeMethod 的方法,用于处理 setAccessible 的问题
|
static Object |
invokeMethod(Method method,
Object target,
Object... args)
重写 invokeMethod 的方法,用于处理 setAccessible 的问题
|
static void |
setField(Field field,
Object target,
Object value)
重写 setField 的方法,用于处理 setAccessible 的问题
|
accessibleConstructor, clearCache, declaresException, doWithFields, doWithFields, doWithLocalFields, doWithLocalMethods, doWithMethods, doWithMethods, findField, findField, findMethod, findMethod, getAllDeclaredMethods, getDeclaredMethods, getUniqueDeclaredMethods, getUniqueDeclaredMethods, handleInvocationTargetException, handleReflectionException, isCglibRenamedMethod, isEqualsMethod, isHashCodeMethod, isObjectMethod, isPublicStaticFinal, isToStringMethod, makeAccessible, makeAccessible, makeAccessible, rethrowException, rethrowRuntimeException, shallowCopyFieldStatepublic static PropertyDescriptor[] getBeanGetters(Class type)
type - 类public static PropertyDescriptor[] getBeanSetters(Class type)
type - 类public static PropertyDescriptor[] getPropertyDescriptors(Class type, boolean read, boolean write)
type - 类read - 读取方法write - 写方法@Nullable public static org.springframework.core.convert.Property getProperty(Class<?> propertyType, String propertyName)
propertyType - 类型propertyName - 属性名public static org.springframework.core.convert.Property getProperty(Class<?> propertyType, PropertyDescriptor propertyDescriptor, String propertyName)
propertyType - 类型propertyDescriptor - PropertyDescriptorpropertyName - 属性名@Nullable public static org.springframework.core.convert.TypeDescriptor getTypeDescriptor(Class<?> propertyType, String propertyName)
propertyType - 类型propertyName - 属性名public static org.springframework.core.convert.TypeDescriptor getTypeDescriptor(Class<?> propertyType, PropertyDescriptor propertyDescriptor, String propertyName)
propertyType - 类型propertyDescriptor - PropertyDescriptorpropertyName - 属性名@Nullable public static Field getField(Class<?> clazz, String fieldName)
clazz - 类信息fieldName - 属性名@Nullable public static <T extends Annotation> T getAnnotation(Class<?> clazz, String fieldName, Class<T> annotationClass)
T - 注解泛型clazz - 类fieldName - 属性名annotationClass - 注解public static void setField(Field field, @Nullable Object target, @Nullable Object value)
field - Fieldtarget - Objectvalue - value@Nullable public static Object getField(Field field, @Nullable Object target)
field - Fieldtarget - Object@Nullable public static Object getField(String fieldName, @Nullable Object target)
fieldName - Field nametarget - Object@Nullable public static Object invokeMethod(Method method, @Nullable Object target)
method - Methodtarget - ObjectCopyright © 2024. All rights reserved.