Class GenericType<T>

  • Type Parameters:
    T - the type provided to the GenericType

    public abstract class GenericType<T>
    extends Object
    Using this class makes it possible to capture a generic/parameterized argument type, such as List<Money>, instead of having to rely on the classical .class construct.
    When you specify a type reference using .class you loose any Generic/Parameterized information, as you cannot write List<Money>.class, only List.class.

    With GenericType you can specify and capture parameterized type information

    You can specify a parameterized type using GenericType:
    var genericType = new GenericType<List<Money>>(){};

    The type/getType() will return List.class
    And genericType/getGenericType() will return ParameterizedType, which can be introspected further


    You can also supply a non-parameterized type to GenericType:
    var genericType = new GenericType<Money>(){};

    In which case type/getType() will return Money.class
    And genericType/getGenericType() will return Money.class
    • Field Detail

      • type

        public final Class<T> type
      • genericType

        public final Type genericType
    • Constructor Detail

      • GenericType

        public GenericType()
    • Method Detail

      • getType

        public Class<T> getType()
      • getGenericType

        public Type getGenericType()