类 ReflectUtil


  • public class ReflectUtil
    extends org.springframework.util.ReflectionUtils
    • 嵌套类概要

      • 从类继承的嵌套类/接口 org.springframework.util.ReflectionUtils

        org.springframework.util.ReflectionUtils.FieldCallback, org.springframework.util.ReflectionUtils.FieldFilter, org.springframework.util.ReflectionUtils.MethodCallback, org.springframework.util.ReflectionUtils.MethodFilter
    • 字段概要

      • 从类继承的字段 org.springframework.util.ReflectionUtils

        COPYABLE_FIELDS, USER_DECLARED_METHODS
    • 构造器概要

      构造器 
      构造器 说明
      ReflectUtil()  
    • 构造器详细资料

      • ReflectUtil

        public ReflectUtil()
    • 方法详细资料

      • 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 - PropertyDescriptor
        propertyName - 属性名
        返回:
        {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 - PropertyDescriptor
        propertyName - 属性名
        返回:
        {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 - Field
        target - Object
        value - value
      • getField

        @Nullable
        public static Object getField​(Field field,
                                      @Nullable
                                      Object target)
        重写 setField 的方法,用于处理 setAccessible 的问题
        参数:
        field - Field
        target - Object
        返回:
        value
      • getField

        @Nullable
        public static Object getField​(String fieldName,
                                      @Nullable
                                      Object target)
        重写 setField 的方法,用于处理 setAccessible 的问题
        参数:
        fieldName - Field name
        target - Object
        返回:
        value
      • invokeMethod

        @Nullable
        public static Object invokeMethod​(Method method,
                                          @Nullable
                                          Object target)
        重写 invokeMethod 的方法,用于处理 setAccessible 的问题
        参数:
        method - Method
        target - Object
        返回:
        value
      • invokeMethod

        @Nullable
        public static Object invokeMethod​(Method method,
                                          @Nullable
                                          Object target,
                                          @Nullable
                                          Object... args)
        重写 invokeMethod 的方法,用于处理 setAccessible 的问题
        参数:
        method - Method
        target - Object
        args - args
        返回:
        value