Class ReflectionHelper


  • public final class ReflectionHelper
    extends Object
    Avoids the usage of Introspector to work on Android too.
    • Method Detail

      • getGetterPropertyName

        public static String getGetterPropertyName​(Member member)
        Returns the JavaBeans property name of the given member.
        Parameters:
        member - never null
        Returns:
        null if the member is neither a field nor a getter method according to the JavaBeans standard
      • isGetterMethod

        public static boolean isGetterMethod​(Method method)
        Checks whether the given method is a valid getter method according to the JavaBeans standard.
        Parameters:
        method - never null
        Returns:
        true if the given method is a getter method
      • hasGetterMethod

        public static boolean hasGetterMethod​(Class<?> containingClass,
                                              String propertyName)
        Parameters:
        containingClass - never null
        propertyName - never null
        Returns:
        true if that getter exists
      • getGetterMethod

        public static Method getGetterMethod​(Class<?> containingClass,
                                             String propertyName)
        Parameters:
        containingClass - never null
        propertyName - never null
        Returns:
        sometimes null
      • hasField

        public static boolean hasField​(Class<?> containingClass,
                                       String fieldName)
        Parameters:
        containingClass - never null
        fieldName - never null
        Returns:
        true if that field exists
      • getField

        public static Field getField​(Class<?> containingClass,
                                     String fieldName)
        Parameters:
        containingClass - never null
        fieldName - never null
        Returns:
        sometimes null
      • getSetterMethod

        public static Method getSetterMethod​(Class<?> containingClass,
                                             Class<?> propertyType,
                                             String propertyName)
        Parameters:
        containingClass - never null
        propertyType - never null
        propertyName - never null
        Returns:
        null if it doesn't exist
      • getSetterMethod

        public static Method getSetterMethod​(Class<?> containingClass,
                                             String propertyName)
        Parameters:
        containingClass - never null
        propertyName - never null
        Returns:
        null if it doesn't exist
      • isMethodOverwritten

        public static boolean isMethodOverwritten​(Method parentMethod,
                                                  Class<?> childClass)
      • assertGetterMethod

        public static void assertGetterMethod​(Method getterMethod,
                                              Class<? extends Annotation> annotationClass)
      • assertReadMethod

        public static void assertReadMethod​(Method readMethod,
                                            Class<? extends Annotation> annotationClass)
      • isMap

        public static boolean isMap​(Type type)
        Parameters:
        type - never null
        Returns:
        true if it is a Map
      • isList

        public static boolean isList​(Type type)
        Parameters:
        type - never null
        Returns:
        true if it is a List
      • transformArrayToList

        public static List<Object> transformArrayToList​(Object arrayObject)