Package org.modelmapper
Class TypeToken<T>
java.lang.Object
org.modelmapper.TypeToken<T>
- Type Parameters:
T
- Represented type
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 Summary
Constructors -
Method Summary
-
Constructor Details
-
TypeToken
protected TypeToken()Creates a new type token forT
.- Throws:
IllegalArgumentException
- ifT
is not provided or is a TypeVariable
-
-
Method Details
-
of
Returns a TypeLiteral for thetype
.- Throws:
IllegalArgumentException
- iftype
is null or if a raw type cannot be resolved
-
equals
-
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
Returns the generic typeT
. -
hashCode
public final int hashCode() -
toString
-