Package org.modelmapper
Class TypeToken<T>
- java.lang.Object
-
- org.modelmapper.TypeToken<T>
-
- Type Parameters:
T
- Represented type
public class TypeToken<T> extends Object
Represents a generic typeT
. 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 Summary
Constructors Modifier Constructor Description protected
TypeToken()
Creates a new type token forT
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
Class<T>
getRawType()
Returns the raw type forT
.Type
getType()
Returns the generic typeT
.int
hashCode()
static <T> TypeToken<T>
of(Type type)
Returns a TypeLiteral for thetype
.String
toString()
-
-
-
Constructor Detail
-
TypeToken
protected TypeToken()
Creates a new type token forT
.- Throws:
IllegalArgumentException
- ifT
is not provided or is a TypeVariable
-
-
Method Detail
-
of
public static <T> TypeToken<T> of(Type type)
Returns a TypeLiteral for thetype
.- Throws:
IllegalArgumentException
- iftype
is null or if a raw type cannot be resolved
-
getRawType
public final Class<T> getRawType()
Returns the raw type forT
.- If
T
is aClass
,T
itself is returned. - If
T
is aParameterizedType
, the raw type is returned - If
T
is aGenericArrayType
, the raw type is returned - If
T
is aTypeVariable
orWildcardType
, the raw type of the first upper bound is returned
- If
-
getType
public final Type getType()
Returns the generic typeT
.
-
-