Package com.google.gson.internal
Class $Gson$Types
- java.lang.Object
-
- com.google.gson.internal.$Gson$Types
-
public final class $Gson$Types extends java.lang.Object
Static methods for working with types.- Author:
- Bob Lee, Jesse Wilson
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.reflect.GenericArrayType
arrayOf(java.lang.reflect.Type componentType)
Returns an array type whose elements are all instances ofcomponentType
.static java.lang.reflect.Type
canonicalize(java.lang.reflect.Type type)
Returns a type that is functionally equal but not necessarily equal according toObject.equals()
.static boolean
equals(java.lang.reflect.Type a, java.lang.reflect.Type b)
Returns true ifa
andb
are equal.static java.lang.reflect.Type
getArrayComponentType(java.lang.reflect.Type array)
Returns the component type of this array type.static java.lang.reflect.Type
getCollectionElementType(java.lang.reflect.Type context, java.lang.Class<?> contextRawType)
Returns the element type of this collection type.static java.lang.reflect.Type[]
getMapKeyAndValueTypes(java.lang.reflect.Type context, java.lang.Class<?> contextRawType)
Returns a two element array containing this map's key and value types in positions 0 and 1 respectively.static java.lang.Class<?>
getRawType(java.lang.reflect.Type type)
static java.lang.reflect.ParameterizedType
newParameterizedTypeWithOwner(java.lang.reflect.Type ownerType, java.lang.reflect.Type rawType, java.lang.reflect.Type... typeArguments)
Returns a new parameterized type, applyingtypeArguments
torawType
and enclosed byownerType
.static java.lang.reflect.Type
resolve(java.lang.reflect.Type context, java.lang.Class<?> contextRawType, java.lang.reflect.Type toResolve)
static java.lang.reflect.WildcardType
subtypeOf(java.lang.reflect.Type bound)
Returns a type that represents an unknown type that extendsbound
.static java.lang.reflect.WildcardType
supertypeOf(java.lang.reflect.Type bound)
Returns a type that represents an unknown supertype ofbound
.static java.lang.String
typeToString(java.lang.reflect.Type type)
-
-
-
Method Detail
-
newParameterizedTypeWithOwner
public static java.lang.reflect.ParameterizedType newParameterizedTypeWithOwner(java.lang.reflect.Type ownerType, java.lang.reflect.Type rawType, java.lang.reflect.Type... typeArguments)
Returns a new parameterized type, applyingtypeArguments
torawType
and enclosed byownerType
.- Returns:
- a
serializable
parameterized type.
-
arrayOf
public static java.lang.reflect.GenericArrayType arrayOf(java.lang.reflect.Type componentType)
Returns an array type whose elements are all instances ofcomponentType
.- Returns:
- a
serializable
generic array type.
-
subtypeOf
public static java.lang.reflect.WildcardType subtypeOf(java.lang.reflect.Type bound)
Returns a type that represents an unknown type that extendsbound
. For example, ifbound
isCharSequence.class
, this returns? extends CharSequence
. Ifbound
isObject.class
, this returns?
, which is shorthand for? extends Object
.
-
supertypeOf
public static java.lang.reflect.WildcardType supertypeOf(java.lang.reflect.Type bound)
Returns a type that represents an unknown supertype ofbound
. For example, ifbound
isString.class
, this returns? super String
.
-
canonicalize
public static java.lang.reflect.Type canonicalize(java.lang.reflect.Type type)
Returns a type that is functionally equal but not necessarily equal according toObject.equals()
. The returned type isSerializable
.
-
getRawType
public static java.lang.Class<?> getRawType(java.lang.reflect.Type type)
-
equals
public static boolean equals(java.lang.reflect.Type a, java.lang.reflect.Type b)
Returns true ifa
andb
are equal.
-
typeToString
public static java.lang.String typeToString(java.lang.reflect.Type type)
-
getArrayComponentType
public static java.lang.reflect.Type getArrayComponentType(java.lang.reflect.Type array)
Returns the component type of this array type.- Throws:
java.lang.ClassCastException
- if this type is not an array.
-
getCollectionElementType
public static java.lang.reflect.Type getCollectionElementType(java.lang.reflect.Type context, java.lang.Class<?> contextRawType)
Returns the element type of this collection type.- Throws:
java.lang.IllegalArgumentException
- if this type is not a collection.
-
getMapKeyAndValueTypes
public static java.lang.reflect.Type[] getMapKeyAndValueTypes(java.lang.reflect.Type context, java.lang.Class<?> contextRawType)
Returns a two element array containing this map's key and value types in positions 0 and 1 respectively.
-
resolve
public static java.lang.reflect.Type resolve(java.lang.reflect.Type context, java.lang.Class<?> contextRawType, java.lang.reflect.Type toResolve)
-
-