Class Generics


  • public class Generics
    extends Object
    Generics utilities borrowed from sundrio's TypedVisitor class.
    • Constructor Detail

      • Generics

        public Generics()
    • Method Detail

      • getClass

        public static Class<?> getClass​(Type type)
        Get the underlying class for a type, or null if the type is a variable type.
        Parameters:
        type - the type
        Returns:
        the underlying class
      • getTypeArguments

        public static <T> List<Class> getTypeArguments​(Class<T> baseClass,
                                                       Class<? extends T> childClass)
        Get the actual type arguments a child class has used to extend a generic base class.
        Type Parameters:
        T - the type of the base class
        Parameters:
        baseClass - the base class
        childClass - the child class
        Returns:
        a list of the raw classes for the actual type arguments