Class Types


  • public final class Types
    extends Object
    Type conversions and generic type manipulations
    Version:
    $Revision: 1 $
    Author:
    Bill Burke
    • Constructor Detail

      • Types

        public Types()
    • Method Detail

      • getActualTypeArgumentsOfAnInterface

        public static Type[] getActualTypeArgumentsOfAnInterface​(Class<?> classToSearch,
                                                                 Class<?> interfaceToFind)
        Given a class and an interfaces, go through the class hierarchy to find the interface and return its type arguments.
        Parameters:
        classToSearch - class
        interfaceToFind - interface to find
        Returns:
        type arguments of the interface
      • findParameterizedTypes

        public static Type[] findParameterizedTypes​(Class<?> root,
                                                    Class<?> searchedFor)
        Search for the given interface or class within the root's class/interface hierarchy. If the searched for class/interface is a generic return an array of real types that fill it out.
        Parameters:
        root - root class
        searchedFor - searched class
        Returns:
        for generic class/interface returns array of real types
      • findClassParameterizedTypes

        public static Type[] findClassParameterizedTypes​(Class<?> root,
                                                         ParameterizedType rootType,
                                                         Class<?> searchedForClass)
      • findInterfaceParameterizedTypes

        public static Type[] findInterfaceParameterizedTypes​(Class<?> root,
                                                             ParameterizedType rootType,
                                                             Class<?> searchedForInterface)
      • getRawType

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