public final class $Gson$Types extends Object
Modifier and Type | Method and Description |
---|---|
static GenericArrayType |
arrayOf(Type componentType)
Returns an array type whose elements are all instances of
componentType . |
static Type |
canonicalize(Type type)
Returns a type that is functionally equal but not necessarily equal according
to
Object.equals() . |
static boolean |
equals(Type a,
Type b)
Returns true if
a and b 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, applying
typeArguments to
rawType and enclosed by ownerType . |
static Type |
resolve(Type context,
Class<?> contextRawType,
Type toResolve) |
static WildcardType |
subtypeOf(Type bound)
Returns a type that represents an unknown type that extends
bound . |
static WildcardType |
supertypeOf(Type bound)
Returns a type that represents an unknown supertype of
bound . |
static String |
typeToString(Type type) |
public static ParameterizedType newParameterizedTypeWithOwner(Type ownerType, Type rawType, Type... typeArguments)
typeArguments
to
rawType
and enclosed by ownerType
.serializable
parameterized type.public static GenericArrayType arrayOf(Type componentType)
componentType
.serializable
generic array type.public static WildcardType subtypeOf(Type bound)
bound
.
For example, if bound
is CharSequence.class
, this returns
? extends CharSequence
. If bound
is Object.class
,
this returns ?
, which is shorthand for ? extends Object
.public static WildcardType supertypeOf(Type bound)
bound
. For
example, if bound
is String.class
, this returns ?
super String
.public static Type canonicalize(Type type)
Object.equals()
. The returned type is
Serializable
.public static Type getArrayComponentType(Type array)
ClassCastException
- if this type is not an array.public static Type getCollectionElementType(Type context, Class<?> contextRawType)
IllegalArgumentException
- if this type is not a collection.public static Type[] getMapKeyAndValueTypes(Type context, Class<?> contextRawType)