类 ReflectUtil
- java.lang.Object
-
- org.springframework.util.ReflectionUtils
-
- me.youm.frame.common.utils.ReflectUtil
-
public class ReflectUtil extends org.springframework.util.ReflectionUtils
-
-
构造器概要
构造器 构造器 说明 ReflectUtil()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static <T extends Annotation>
TgetAnnotation(Class<?> clazz, String fieldName, Class<T> annotationClass)获取 所有 field 属性上的注解static PropertyDescriptor[]getBeanGetters(Class type)获取 Bean 的所有 get方法static PropertyDescriptor[]getBeanSetters(Class type)获取 Bean 的所有 set方法static FieldgetField(Class<?> clazz, String fieldName)获取 类属性static ObjectgetField(Field field, Object target)重写 setField 的方法,用于处理 setAccessible 的问题static ObjectgetField(String fieldName, Object target)重写 setField 的方法,用于处理 setAccessible 的问题static org.springframework.core.convert.PropertygetProperty(Class<?> propertyType, PropertyDescriptor propertyDescriptor, String propertyName)获取 bean 的属性信息static org.springframework.core.convert.PropertygetProperty(Class<?> propertyType, String propertyName)获取 bean 的属性信息static PropertyDescriptor[]getPropertyDescriptors(Class type, boolean read, boolean write)获取 Bean 的所有 PropertyDescriptorstatic org.springframework.core.convert.TypeDescriptorgetTypeDescriptor(Class<?> propertyType, PropertyDescriptor propertyDescriptor, String propertyName)获取 类属性信息static org.springframework.core.convert.TypeDescriptorgetTypeDescriptor(Class<?> propertyType, String propertyName)获取 bean 的属性信息static ObjectinvokeMethod(Method method, Object target)重写 invokeMethod 的方法,用于处理 setAccessible 的问题static ObjectinvokeMethod(Method method, Object target, Object... args)重写 invokeMethod 的方法,用于处理 setAccessible 的问题static voidsetField(Field field, Object target, Object value)重写 setField 的方法,用于处理 setAccessible 的问题-
从类继承的方法 org.springframework.util.ReflectionUtils
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, shallowCopyFieldState
-
-
-
-
方法详细资料
-
getBeanGetters
public static PropertyDescriptor[] getBeanGetters(Class type)
获取 Bean 的所有 get方法- 参数:
type- 类- 返回:
- PropertyDescriptor数组
-
getBeanSetters
public static PropertyDescriptor[] getBeanSetters(Class type)
获取 Bean 的所有 set方法- 参数:
type- 类- 返回:
- PropertyDescriptor数组
-
getPropertyDescriptors
public static PropertyDescriptor[] getPropertyDescriptors(Class type, boolean read, boolean write)
获取 Bean 的所有 PropertyDescriptor- 参数:
type- 类read- 读取方法write- 写方法- 返回:
- PropertyDescriptor数组
-
getProperty
@Nullable public static org.springframework.core.convert.Property getProperty(Class<?> propertyType, String propertyName)
获取 bean 的属性信息- 参数:
propertyType- 类型propertyName- 属性名- 返回:
- {Property}
-
getProperty
public static org.springframework.core.convert.Property getProperty(Class<?> propertyType, PropertyDescriptor propertyDescriptor, String propertyName)
获取 bean 的属性信息- 参数:
propertyType- 类型propertyDescriptor- PropertyDescriptorpropertyName- 属性名- 返回:
- {Property}
-
getTypeDescriptor
@Nullable public static org.springframework.core.convert.TypeDescriptor getTypeDescriptor(Class<?> propertyType, String propertyName)
获取 bean 的属性信息- 参数:
propertyType- 类型propertyName- 属性名- 返回:
- {Property}
-
getTypeDescriptor
public static org.springframework.core.convert.TypeDescriptor getTypeDescriptor(Class<?> propertyType, PropertyDescriptor propertyDescriptor, String propertyName)
获取 类属性信息- 参数:
propertyType- 类型propertyDescriptor- PropertyDescriptorpropertyName- 属性名- 返回:
- {Property}
-
getField
@Nullable public static Field getField(Class<?> clazz, String fieldName)
获取 类属性- 参数:
clazz- 类信息fieldName- 属性名- 返回:
- Field
-
getAnnotation
@Nullable public static <T extends Annotation> T getAnnotation(Class<?> clazz, String fieldName, Class<T> annotationClass)
获取 所有 field 属性上的注解- 类型参数:
T- 注解泛型- 参数:
clazz- 类fieldName- 属性名annotationClass- 注解- 返回:
- 注解
-
setField
public static void setField(Field field, @Nullable Object target, @Nullable Object value)
重写 setField 的方法,用于处理 setAccessible 的问题- 参数:
field- Fieldtarget- Objectvalue- value
-
getField
@Nullable public static Object getField(Field field, @Nullable Object target)
重写 setField 的方法,用于处理 setAccessible 的问题- 参数:
field- Fieldtarget- Object- 返回:
- value
-
getField
@Nullable public static Object getField(String fieldName, @Nullable Object target)
重写 setField 的方法,用于处理 setAccessible 的问题- 参数:
fieldName- Field nametarget- Object- 返回:
- value
-
invokeMethod
@Nullable public static Object invokeMethod(Method method, @Nullable Object target)
重写 invokeMethod 的方法,用于处理 setAccessible 的问题- 参数:
method- Methodtarget- Object- 返回:
- value
-
-