Class TypeToken<T>

  • Type Parameters:
    T - The type represented by this TypeToken.

    public abstract class TypeToken<T>
    extends java.lang.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();
    Author:
    Wouter Coekaerts
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected TypeToken()
      Constructs a type token.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      static <T> TypeToken<T> get​(java.lang.Class<T> type)
      Gets type token for the given Class instance.
      static TypeToken<?> get​(java.lang.reflect.Type type)
      Gets type token for the given Type instance.
      java.lang.reflect.Type getType()  
      int hashCode()  
      • Methods inherited from class java.lang.Object

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

      • TypeToken

        protected TypeToken()
        Constructs a type token.
    • Method Detail

      • getType

        public java.lang.reflect.Type getType()
      • get

        public static <T> TypeToken<T> get​(java.lang.Class<T> type)
        Gets type token for the given Class instance.
      • get

        public static TypeToken<?> get​(java.lang.reflect.Type type)
        Gets type token for the given Type instance.
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object