|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.gson.reflect.TypeToken<T>
public abstract class TypeToken<T>
Represents a generic type T.
You can use this class to get the generic type for a class. For example,
to get the generic type for Collection<Foo>, you can use:
Type typeOfCollectionOfFoo = new TypeToken<Collection<Foo>>(){}.getType()
Assumes Type implements equals() and hashCode()
as a value (as opposed to identity) comparison.
Also implements isAssignableFrom(Type) to check type-safe
assignability.
| Method Summary | ||
|---|---|---|
boolean |
equals(Object o)
Method to test equality. |
|
static
|
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. |
|
Class<? super T> |
getRawType()
Gets the raw type. |
|
Type |
getType()
Gets underlying Type instance. |
|
int |
hashCode()
Hashcode for this object. |
|
boolean |
isAssignableFrom(Class<?> cls)
Check if this type is assignable from the given class object. |
|
boolean |
isAssignableFrom(Type from)
Check if this type is assignable from the given Type. |
|
boolean |
isAssignableFrom(TypeToken<?> token)
Check if this type is assignable from the given type token. |
|
String |
toString()
Returns a string representation of this object. |
|
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public Class<? super T> getRawType()
public Type getType()
Type instance.
public boolean isAssignableFrom(Class<?> cls)
public boolean isAssignableFrom(Type from)
public boolean isAssignableFrom(TypeToken<?> token)
public int hashCode()
hashCode in class Objectpublic boolean equals(Object o)
equals in class Objectpublic String toString()
toString in class Objectpublic static TypeToken<?> get(Type type)
Type instance.
public static <T> TypeToken<T> get(Class<T> type)
Class instance.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||