- java.lang.Object
-
- io.leangen.geantyref.TypeToken<T>
-
- Type Parameters:
T
- The type represented by this TypeToken.
public abstract class TypeToken<T> extends java.lang.Object
Wrapper aroundType
. 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();
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
private java.lang.reflect.AnnotatedType
extractType()
static <T> TypeToken<T>
get(java.lang.Class<T> type)
Gets type token for the givenClass
instance.static TypeToken<?>
get(java.lang.reflect.Type type)
Gets type token for the givenType
instance.java.lang.reflect.AnnotatedType
getAnnotatedType()
java.lang.reflect.AnnotatedType
getCanonicalType()
java.lang.reflect.Type
getType()
int
hashCode()
-
-
-
Method Detail
-
get
public static <T> TypeToken<T> get(java.lang.Class<T> type)
Gets type token for the givenClass
instance.- Type Parameters:
T
- The generic type captured by the token- Parameters:
type
- The class from which the token is created- Returns:
- TypeToken corresponding to the provided class
-
get
public static TypeToken<?> get(java.lang.reflect.Type type)
Gets type token for the givenType
instance.- Parameters:
type
- The type from which the token is created- Returns:
- TypeToken corresponding to the provided type
-
getType
public java.lang.reflect.Type getType()
-
getAnnotatedType
public java.lang.reflect.AnnotatedType getAnnotatedType()
-
getCanonicalType
public java.lang.reflect.AnnotatedType getCanonicalType()
-
extractType
private java.lang.reflect.AnnotatedType extractType()
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-