Class BeanUtils


  • public abstract class BeanUtils
    extends Object
    Author:
    Bob Lee, Jesse Wilson, Shaojin Wen
    • Constructor Detail

      • BeanUtils

        public BeanUtils()
    • Method Detail

      • getRecordFieldNames

        public static String[] getRecordFieldNames​(Class<?> recordType)
      • fields

        public static void fields​(Class objectClass,
                                  Consumer<Field> fieldReaders)
      • getMethod

        public static Method getMethod​(Class objectClass,
                                       String methodName)
      • fluentSetter

        public static Method fluentSetter​(Class objectClass,
                                          String methodName,
                                          Class paramType)
      • getMethod

        public static Method getMethod​(Class objectClass,
                                       Method signature)
      • getDeclaredField

        public static Field getDeclaredField​(Class objectClass,
                                             String fieldName)
      • getSetter

        public static Method getSetter​(Class objectClass,
                                       String methodName)
      • declaredFields

        public static void declaredFields​(Class objectClass,
                                          Consumer<Field> fieldConsumer)
        ignore static fields
      • staticMethod

        public static void staticMethod​(Class objectClass,
                                        Consumer<Method> methodConsumer)
      • buildMethod

        public static Method buildMethod​(Class objectClass,
                                         String methodName)
      • getConstructor

        public static Constructor[] getConstructor​(Class objectClass)
      • hasPublicDefaultConstructor

        public static boolean hasPublicDefaultConstructor​(Class objectClass)
      • getDefaultConstructor

        public static Constructor getDefaultConstructor​(Class objectClass,
                                                        boolean includeNoneStaticMember)
      • setters

        public static void setters​(Class objectClass,
                                   Consumer<Method> methodConsumer)
      • setters

        public static void setters​(Class objectClass,
                                   boolean checkPrefix,
                                   Consumer<Method> methodConsumer)
      • annotationMethods

        public static void annotationMethods​(Class objectClass,
                                             Consumer<Method> methodConsumer)
      • isWriteEnumAsJavaBean

        public static boolean isWriteEnumAsJavaBean​(Class clazz)
      • getEnumAnnotationNames

        public static String[] getEnumAnnotationNames​(Class enumClass)
      • getters

        public static void getters​(Class objectClass,
                                   Consumer<Method> methodConsumer)
      • getters

        public static void getters​(Class objectClass,
                                   Class mixinSource,
                                   boolean kotlin,
                                   Consumer<Method> methodConsumer)
      • isRecord

        public static boolean isRecord​(Class objectClass)
      • setterName

        public static String setterName​(String methodName,
                                        String namingStrategy)
      • setterName

        public static String setterName​(String methodName,
                                        int prefixLength)
      • getterName

        public static String getterName​(Method method,
                                        boolean kotlin,
                                        String namingStrategy)
      • getField

        public static Field getField​(Class objectClass,
                                     Method method)
      • getterName

        public static String getterName​(String methodName,
                                        String namingStrategy)
      • fieldName

        public static String fieldName​(String methodName,
                                       String namingStrategy)
      • newParameterizedTypeWithOwner

        public static ParameterizedType newParameterizedTypeWithOwner​(Type ownerType,
                                                                      Type rawType,
                                                                      Type... typeArguments)
        Returns a new parameterized type, applying typeArguments to rawType and enclosed by ownerType.
        Returns:
        a serializable parameterized type.
      • arrayOf

        public static GenericArrayType arrayOf​(Type componentType)
        Returns an array type whose elements are all instances of componentType.
        Returns:
        a serializable generic array type.
      • subtypeOf

        public static WildcardType subtypeOf​(Type bound)
        Returns a type that represents an unknown type that extends bound. For example, if bound is CharSequence.class, this returns ? extends CharSequence. If bound is Object.class, this returns ?, which is shorthand for ? extends Object.
      • supertypeOf

        public static WildcardType supertypeOf​(Type bound)
        Returns a type that represents an unknown supertype of bound. For example, if bound is String.class, this returns ? super String.
      • canonicalize

        public static Type canonicalize​(Type type)
        Returns a type that is functionally equal but not necessarily equal according to Object.equals(). The returned type is Serializable.
      • getRawType

        public static Class<?> getRawType​(Type type)
      • equals

        public static boolean equals​(Type a,
                                     Type b)
        Returns true if a and b are equal.
      • typeToString

        public static String typeToString​(Type type)
      • resolve

        public static Type resolve​(Type context,
                                   Class<?> contextRawType,
                                   Type toResolve)
      • findAnnotation

        public static <A extends Annotation> A findAnnotation​(AnnotatedElement element,
                                                              Class<A> annotationType)
        Find the first annotation of annotationType that is either directly present, meta-present, or indirectly present on the supplied element.

        If the element is a class and the annotation is neither directly present nor meta-present on the class, this method will additionally search on interfaces implemented by the class before finding an annotation that is indirectly present on the class.

        Type Parameters:
        A - the annotation
        Parameters:
        element - the element on which to search for the annotation
        annotationType - the annotation type of need to search
        Returns:
        the searched annotation type
      • findAnnotation

        public static <A extends Annotation> A findAnnotation​(Annotation annotation,
                                                              Class<A> annotationType)
        If the annotation's annotationType is not annotationType, then to find the first annotation of annotationType that is either directly present, meta-present, or indirectly present on the supplied element.
        Type Parameters:
        A - the searched annotation type
        Parameters:
        annotation - annotation
        annotationType - the annotation type of need to search
        Returns:
        the searched annotation
      • processJacksonJsonIgnore

        public static void processJacksonJsonIgnore​(FieldInfo fieldInfo,
                                                    Annotation annotation)
      • isNoneStaticMemberClass

        public static boolean isNoneStaticMemberClass​(Class objectClass,
                                                      Class memberClass)
      • setNoneStaticMemberClassParent

        public static void setNoneStaticMemberClassParent​(Object object,
                                                          Object parent)
      • cleanupCache

        public static void cleanupCache​(Class objectClass)
      • cleanupCache

        public static void cleanupCache​(ClassLoader classLoader)
      • processJSONType1x

        public static void processJSONType1x​(BeanInfo beanInfo,
                                             Annotation jsonType1x,
                                             Method method)
      • processJacksonJsonFormat

        public static void processJacksonJsonFormat​(FieldInfo fieldInfo,
                                                    Annotation annotation)
      • processJacksonJsonFormat

        public static void processJacksonJsonFormat​(BeanInfo beanInfo,
                                                    Annotation annotation)
      • processJacksonJsonInclude

        public static void processJacksonJsonInclude​(BeanInfo beanInfo,
                                                     Annotation annotation)
      • processJacksonJsonInclude

        public static void processJacksonJsonInclude​(FieldInfo fieldInfo,
                                                     Annotation annotation)
      • processJacksonJsonUnwrapped

        public static void processJacksonJsonUnwrapped​(FieldInfo fieldInfo,
                                                       Annotation annotation)
      • processJacksonJsonTypeName

        public static void processJacksonJsonTypeName​(BeanInfo beanInfo,
                                                      Annotation annotation)
      • processJacksonJsonSubTypesType

        public static void processJacksonJsonSubTypesType​(BeanInfo beanInfo,
                                                          int index,
                                                          Annotation annotation)
      • processGsonSerializedName

        public static void processGsonSerializedName​(FieldInfo fieldInfo,
                                                     Annotation annotation)
      • isExtendedMap

        public static boolean isExtendedMap​(Class objectClass)