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