Class Reflection


  • public final class Reflection
    extends java.lang.Object
    Reflection utilities.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Class<?> getClass​(java.lang.reflect.Type type)
      Get the Class for a generic type.
      static boolean isGetter​(java.lang.reflect.Method method)
      Is the given method a JavaBeans getter.
      static boolean isListIndex​(java.lang.reflect.Method method)
      Does the given method represent a List index.
      static java.lang.reflect.Type resultType​(java.lang.reflect.Type declaringType, java.lang.reflect.Type type)
      Get the resulting type of invoking a method.
      static java.lang.reflect.Type variableType​(java.lang.reflect.ParameterizedType type, java.lang.reflect.TypeVariable<?> variable)
      Get the type for a class type variable.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getClass

        public static java.lang.Class<?> getClass​(java.lang.reflect.Type type)
        Get the Class for a generic type.
        Parameters:
        type - Class or ParameterizedType
        Returns:
        class class
        Throws:
        java.lang.IllegalArgumentException - if type doesn't represent a class
      • isGetter

        public static boolean isGetter​(java.lang.reflect.Method method)
        Is the given method a JavaBeans getter.
        Parameters:
        method - method to test
        Returns:
        true if method is a getter
      • isListIndex

        public static boolean isListIndex​(java.lang.reflect.Method method)
        Does the given method represent a List index.
        Parameters:
        method - method to test
        Returns:
        true if list index
      • resultType

        public static java.lang.reflect.Type resultType​(java.lang.reflect.Type declaringType,
                                                        java.lang.reflect.Type type)
        Get the resulting type of invoking a method.
        Parameters:
        declaringType - declaring class of the method
        type - return type of method
        Returns:
        resulting type or null if not known
      • variableType

        public static java.lang.reflect.Type variableType​(java.lang.reflect.ParameterizedType type,
                                                          java.lang.reflect.TypeVariable<?> variable)
        Get the type for a class type variable.
        Parameters:
        type - the owning type
        variable - the variable
        Returns:
        type or null