Class TypeToken<T>

java.lang.Object
io.leangen.geantyref.TypeToken<T>
Type Parameters:
T - The type represented by this TypeToken.

public abstract class TypeToken<T> extends Object
Wrapper around Type. You can use this to create instances of Type for a type known at compile time. For example, to get the Type that represents List<String>: Type listOfString = new TypeToken<List<String>>(){}.getType();
  • Field Details

  • Constructor Details

    • TypeToken

      protected TypeToken()
      Constructs a type token.
    • TypeToken

      private TypeToken(AnnotatedType type)
  • Method Details

    • get

      public static <T> TypeToken<T> get(Class<T> type)
      Gets type token for the given Class instance.
      Type Parameters:
      T - The generic type captured by the token
      Parameters:
      type - The class from which the token is created
      Returns:
      TypeToken corresponding to the provided class
    • get

      public static TypeToken<?> get(Type type)
      Gets type token for the given Type instance.
      Parameters:
      type - The type from which the token is created
      Returns:
      TypeToken corresponding to the provided type
    • getType

      public Type getType()
    • getAnnotatedType

      public AnnotatedType getAnnotatedType()
    • getCanonicalType

      public AnnotatedType getCanonicalType()
    • extractType

      private AnnotatedType extractType()
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object