Class TypeToken<T>

java.lang.Object
org.modelmapper.TypeToken<T>
Type Parameters:
T - Represented type

public class TypeToken<T> extends Object
Represents a generic type T. Subclassing TypeToken allows for type information to be preserved at runtime.

Example: To create a type literal for List<String>, you can create an empty anonymous inner class:

TypeToken<List<String>> list = new TypeToken<List<String>>();

  • Constructor Details

    • TypeToken

      protected TypeToken()
      Creates a new type token for T.
      Throws:
      IllegalArgumentException - if T is not provided or is a TypeVariable
  • Method Details

    • of

      public static <T> TypeToken<T> of(Type type)
      Returns a TypeLiteral for the type.
      Throws:
      IllegalArgumentException - if type is null or if a raw type cannot be resolved
    • equals

      public final boolean equals(Object o)
      Overrides:
      equals in class Object
    • getRawType

      public final Class<T> getRawType()
      Returns the raw type for T.
    • getType

      public final Type getType()
      Returns the generic type T.
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public final String toString()
      Overrides:
      toString in class Object