Class Reflector


  • final class Reflector
    extends java.lang.Object
    The Reflector object is used to determine the type of a generic type. This is used when the type of an XML annotation is not explicitly and the schema scanner needs to determine via reflection what the generic parameters are of a specific type. In particular this is used to determine the parameters within a list annotated with the ElementList annotation. This also has special handling for arrays within generic collections.
    • Constructor Summary

      Constructors 
      Constructor Description
      Reflector()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.Class getArrayClass​(java.lang.reflect.Type type)
      This is used to extract an array class from the specified.
      private static java.lang.Class getClass​(java.lang.reflect.ParameterizedType type)
      This is used to extract the class from the specified type.
      private static java.lang.Class getClass​(java.lang.reflect.Type type)
      This is used to extract the class from the specified type.
      private static java.lang.Class[] getClasses​(java.lang.reflect.ParameterizedType type)
      This is used to extract the class from the specified type.
      static java.lang.Class getDependent​(java.lang.reflect.Field field)
      This method is used to acquire a generic parameter dependent from the specified field.
      static java.lang.Class[] getDependents​(java.lang.reflect.Field field)
      This method is used to acquire generic parameter dependents from the specified field.
      private static java.lang.Class getGenericClass​(java.lang.reflect.Type type)
      This is used to extract the class from the specified type.
      static java.lang.String getName​(java.lang.String name)
      This is used to acquire a bean name for a method or field name.
      static java.lang.Class getParameterDependent​(java.lang.reflect.Constructor factory, int index)
      This method is used to acquire a generic parameter dependent from the specified parameter type.
      static java.lang.Class getParameterDependent​(java.lang.reflect.Method method, int index)
      This method is used to acquire a generic parameter dependent from the specified parameter type.
      static java.lang.Class[] getParameterDependents​(java.lang.reflect.Constructor factory, int index)
      This method is used to acquire a generic parameter dependent from the specified parameter type.
      static java.lang.Class[] getParameterDependents​(java.lang.reflect.Method method, int index)
      This method is used to acquire a generic parameter dependent from the specified parameter type.
      private static java.lang.reflect.ParameterizedType getParameterType​(java.lang.reflect.Constructor factory, int index)
      This is used to acquire the parameterized types from the given constructors parameter class at the specified index position.
      private static java.lang.reflect.ParameterizedType getParameterType​(java.lang.reflect.Method method, int index)
      This is used to acquire the parameterized types from the given methods parameter class at the specified index position.
      static java.lang.Class getReturnDependent​(java.lang.reflect.Method method)
      This method is used to acquire a generic parameter dependent from the method return type.
      static java.lang.Class[] getReturnDependents​(java.lang.reflect.Method method)
      This method is used to acquire a generic parameter dependent from the method return type.
      private static java.lang.reflect.ParameterizedType getReturnType​(java.lang.reflect.Method method)
      This is used to acquire the parameterized types from the given methods return class.
      private static java.lang.reflect.ParameterizedType getType​(java.lang.reflect.Field field)
      This is used to acquire the parameterized types from the given field.
      private static boolean isAcronym​(char[] array)
      This is used to determine if the provided array of characters represents an acronym.
      private static boolean isUpperCase​(char value)
      This is used to determine if the provided character is an upper case character.
      private static char toLowerCase​(char value)
      This is used to convert the provided character to lower case.
      • Methods inherited from class java.lang.Object

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

      • Reflector

        Reflector()
    • Method Detail

      • getDependent

        public static java.lang.Class getDependent​(java.lang.reflect.Field field)
        This method is used to acquire a generic parameter dependent from the specified field. This will acquire the field class and attempt to extract the first generic parameter type from that field. If there is a generic parameter then the class of that parameter is returned from this method.
        Parameters:
        field - this is the field to acquire the dependent class
        Returns:
        this returns the generic parameter class declared
      • getDependents

        public static java.lang.Class[] getDependents​(java.lang.reflect.Field field)
        This method is used to acquire generic parameter dependents from the specified field. This will acquire the field class and attempt to extract all of the generic parameter types from that field. If there is a generic parameter then the class of that parameter is returned from this method.
        Parameters:
        field - this is the field to acquire the dependent types
        Returns:
        this returns the generic parameter classes declared
      • getType

        private static java.lang.reflect.ParameterizedType getType​(java.lang.reflect.Field field)
        This is used to acquire the parameterized types from the given field. If the field class has been parameterized then this will return the parameters that have been declared on that class.
        Parameters:
        field - this is the field to acquire the parameters from
        Returns:
        this will return the parameterized types for the field
      • getReturnDependent

        public static java.lang.Class getReturnDependent​(java.lang.reflect.Method method)
        This method is used to acquire a generic parameter dependent from the method return type. This will acquire the return type and attempt to extract the first generic parameter type from that type. If there is a generic parameter then the class of that parameter is returned from this method.
        Parameters:
        method - this is the method to acquire the dependent of
        Returns:
        this returns the generic parameter class declared
      • getReturnDependents

        public static java.lang.Class[] getReturnDependents​(java.lang.reflect.Method method)
        This method is used to acquire a generic parameter dependent from the method return type. This will acquire the return type and attempt to extract the first generic parameter type from that type. If there is a generic parameter then the class of that parameter is returned from this method.
        Parameters:
        method - this is the method to acquire the dependent of
        Returns:
        this returns the generic parameter class declared
      • getReturnType

        private static java.lang.reflect.ParameterizedType getReturnType​(java.lang.reflect.Method method)
        This is used to acquire the parameterized types from the given methods return class. If the return type class is parameterized then this will return the parameters that have been declared on that class, otherwise null is returned.
        Parameters:
        method - this is the method to acquire the parameters from
        Returns:
        this returns the parameterized types for the method
      • getParameterDependent

        public static java.lang.Class getParameterDependent​(java.lang.reflect.Method method,
                                                            int index)
        This method is used to acquire a generic parameter dependent from the specified parameter type. This will acquire the type for the parameter at the specified index and attempt to extract the first generic parameter type from that type. If there is a generic parameter then the class of that parameter is returned from this method, otherwise null is returned.
        Parameters:
        method - this is the method to acquire the dependent of
        index - this is the index to acquire the parameter from
        Returns:
        this returns the generic parameter class declared
      • getParameterDependents

        public static java.lang.Class[] getParameterDependents​(java.lang.reflect.Method method,
                                                               int index)
        This method is used to acquire a generic parameter dependent from the specified parameter type. This will acquire the type for the parameter at the specified index and attempt to extract the first generic parameter type from that type. If there is a generic parameter then the class of that parameter is returned from this method, otherwise null is returned.
        Parameters:
        method - this is the method to acquire the dependent of
        index - this is the index to acquire the parameter from
        Returns:
        this returns the generic parameter class declared
      • getParameterDependent

        public static java.lang.Class getParameterDependent​(java.lang.reflect.Constructor factory,
                                                            int index)
        This method is used to acquire a generic parameter dependent from the specified parameter type. This will acquire the type for the parameter at the specified index and attempt to extract the first generic parameter type from that type. If there is a generic parameter then the class of that parameter is returned from this method, otherwise null is returned.
        Parameters:
        factory - this is the constructor to acquire the dependent
        index - this is the index to acquire the parameter from
        Returns:
        this returns the generic parameter class declared
      • getParameterDependents

        public static java.lang.Class[] getParameterDependents​(java.lang.reflect.Constructor factory,
                                                               int index)
        This method is used to acquire a generic parameter dependent from the specified parameter type. This will acquire the type for the parameter at the specified index and attempt to extract the first generic parameter type from that type. If there is a generic parameter then the class of that parameter is returned from this method, otherwise null is returned.
        Parameters:
        factory - this is the constructor to acquire the dependent
        index - this is the index to acquire the parameter from
        Returns:
        this returns the generic parameter class declared
      • getParameterType

        private static java.lang.reflect.ParameterizedType getParameterType​(java.lang.reflect.Method method,
                                                                            int index)
        This is used to acquire the parameterized types from the given methods parameter class at the specified index position. If the parameter class is parameterized this returns the parameters that have been declared on that class.
        Parameters:
        method - this is the method to acquire the parameters from
        index - this is the index to acquire the parameter from
        Returns:
        this returns the parameterized types for the method
      • getParameterType

        private static java.lang.reflect.ParameterizedType getParameterType​(java.lang.reflect.Constructor factory,
                                                                            int index)
        This is used to acquire the parameterized types from the given constructors parameter class at the specified index position. If the parameter class is parameterized this returns the parameters that have been declared on that class.
        Parameters:
        factory - this is constructor method to acquire the parameters
        index - this is the index to acquire the parameter from
        Returns:
        this returns the parameterized types for the method
      • getClass

        private static java.lang.Class getClass​(java.lang.reflect.ParameterizedType type)
        This is used to extract the class from the specified type. If there are no actual generic type arguments to the specified type then this will return null. Otherwise this will return the actual class, regardless of whether the class is an array.
        Parameters:
        type - this is the type to extract the class from
        Returns:
        this returns the class type from the first parameter
      • getClasses

        private static java.lang.Class[] getClasses​(java.lang.reflect.ParameterizedType type)
        This is used to extract the class from the specified type. If there are no actual generic type arguments to the specified type then this will return null. Otherwise this will return the actual class, regardless of whether the class is an array.
        Parameters:
        type - this is the type to extract the class from
        Returns:
        this returns the class type from the first parameter
      • getClass

        private static java.lang.Class getClass​(java.lang.reflect.Type type)
        This is used to extract the class from the specified type. If there are no actual generic type arguments to the specified type then this will return null. Otherwise this will return the actual class, regardless of whether the class is an array.
        Parameters:
        type - this is the type to extract the class from
        Returns:
        this returns the class type from the first parameter
      • getGenericClass

        private static java.lang.Class getGenericClass​(java.lang.reflect.Type type)
        This is used to extract the class from the specified type. If there are no actual generic type arguments to the specified type then this will return null. Otherwise this will return the actual class, regardless of whether the class is an array.
        Parameters:
        type - this is the type to extract the class from
        Returns:
        this returns the class type from the first parameter
      • getArrayClass

        private static java.lang.Class getArrayClass​(java.lang.reflect.Type type)
        This is used to extract an array class from the specified. If a class can be extracted from the type then the array class is created by reflective creating a zero length array with the component type of the array and returning the array class.
        Parameters:
        type - this is the type to extract the class from
        Returns:
        this returns the class type from the array type
      • getName

        public static java.lang.String getName​(java.lang.String name)
        This is used to acquire a bean name for a method or field name. A bean name is the name of a method or field with the first character decapitalized. An exception to this is when a method or field starts with an acronym, in such a case the name will remain unchanged from the original name.
        Parameters:
        name - this is the name to convert to a bean name
        Returns:
        this returns the bean value for the given name
      • isAcronym

        private static boolean isAcronym​(char[] array)
        This is used to determine if the provided array of characters represents an acronym. The array of characters is considered an acronym if the first and second characters are upper case.
        Parameters:
        array - the array to evaluate whether it is an acronym
        Returns:
        this returns true if the provided array is an acronym
      • toLowerCase

        private static char toLowerCase​(char value)
        This is used to convert the provided character to lower case. The character conversion is done for all unicode characters.
        Parameters:
        value - this is the value that is to be converted
        Returns:
        this returns the provided character in lower case
      • isUpperCase

        private static boolean isUpperCase​(char value)
        This is used to determine if the provided character is an upper case character. This can deal with unicode characters.
        Parameters:
        value - this is the value that is to be evaluated
        Returns:
        this returns true if the character is upper case