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 GenericArrayTypeReturns an array type whose elements are all instances ofcomponentType.static Typecanonicalize(Type type) Returns a type that is functionally equal but not necessarily equal according toObject.equals().static booleanReturns true ifaandbare equal.static TypegetArrayComponentType(Type array) Returns the component type of this array type.static TypegetCollectionElementType(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 ParameterizedTypenewParameterizedTypeWithOwner(Type ownerType, Type rawType, Type... typeArguments) Returns a new parameterized type, applyingtypeArgumentstorawTypeand enclosed byownerType.static Typestatic WildcardTypeReturns a type that represents an unknown type that extendsbound.static WildcardTypesupertypeOf(Type bound) Returns a type that represents an unknown supertype ofbound.static StringtypeToString(Type type)
-
Method Details
-
newParameterizedTypeWithOwner
public static ParameterizedType newParameterizedTypeWithOwner(Type ownerType, Type rawType, Type... typeArguments) Returns a new parameterized type, applyingtypeArgumentstorawTypeand enclosed byownerType.- Returns:
- a
serializableparameterized type.
-
arrayOf
Returns an array type whose elements are all instances ofcomponentType.- Returns:
- a
serializablegeneric array type.
-
subtypeOf
Returns a type that represents an unknown type that extendsbound. For example, ifboundisCharSequence.class, this returns? extends CharSequence. IfboundisObject.class, this returns?, which is shorthand for? extends Object. -
supertypeOf
Returns a type that represents an unknown supertype ofbound. For example, ifboundisString.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
-
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
-
resolve
-