Class TypeArguments


  • public final class TypeArguments
    extends Object
    Utility methods for dealing with generic type arguments.
    • Method Detail

      • get

        public static Type[] get​(Type type)
        Get all type arguments from a generic type, for example [Foo,Bar] from Map<Foo,Bar>.
        Parameters:
        type - The generic type
        Returns:
        Array of type arguments
      • get

        public static Type get​(Type type,
                               int index)
        Get an indexed type argument from a generic type, for example Bar from Map<Foo,Bar>.
        Parameters:
        type - The generic type
        index - The argument index
        Returns:
        Indexed type argument; Object.class if the given type is a raw class
      • getRawType

        public static Class<?> getRawType​(Type type)
        Get the erased raw Class for a generic type, for example Map from Map<Foo,Bar>.
        Parameters:
        type - The generic type
        Returns:
        Erased raw type