Class TypeLiteral<T>

  • Type Parameters:
    T - the type represented

    public abstract class TypeLiteral<T>
    extends java.lang.Object
    Allows creation of parameterized types by sub-classing this class.

    For example, to create a type List<? extends String> write:

    Type type = new TypeLiteral<List<? extends String>>() {}.getType()
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected TypeLiteral()
      Constructs a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Class<T> getRawType()
      Returns the raw type.
      java.lang.reflect.Type getType()
      Returns the type represented.
      • Methods inherited from class java.lang.Object

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

      • TypeLiteral

        protected TypeLiteral()
        Constructs a new instance.
    • Method Detail

      • getType

        public final java.lang.reflect.Type getType()
        Returns the type represented.
        Returns:
        the type represented, never null
      • getRawType

        public final java.lang.Class<T> getRawType()
        Returns the raw type.
        Returns:
        the raw type, never null