T
- The type represented by this TypeToken.public abstract class TypeToken<T> extends Object
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();
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
static <T> TypeToken<T> |
get(Class<T> type)
Gets type token for the given
Class instance. |
static TypeToken<?> |
get(Type type)
Gets type token for the given
Type instance. |
AnnotatedType |
getAnnotatedType() |
AnnotatedType |
getCanonicalType() |
Type |
getType() |
int |
hashCode() |
public static <T> TypeToken<T> get(Class<T> type)
Class
instance.T
- The generic type captured by the tokentype
- The class from which the token is createdpublic static TypeToken<?> get(Type type)
Type
instance.type
- The type from which the token is createdpublic Type getType()
public AnnotatedType getAnnotatedType()
public AnnotatedType getCanonicalType()
Copyright © 2016–2019. All rights reserved.