Package com.google.gson.internal
Class $Gson$Types
- java.lang.Object
-
- com.google.gson.internal.$Gson$Types
-
public final class $Gson$Types extends 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 GenericArrayTypearrayOf(Type componentType)Returns 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 booleanequals(Type a, Type b)Returns 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 Typeresolve(Type context, Class<?> contextRawType, Type toResolve)static WildcardTypesubtypeOf(Type bound)Returns 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 Detail
-
newParameterizedTypeWithOwner
public static ParameterizedType newParameterizedTypeWithOwner(Type ownerType, Type rawType, Type... typeArguments)
Returns a new parameterized type, applyingtypeArgumentstorawTypeand enclosed byownerType.- Returns:
- a
serializableparameterized type.
-
arrayOf
public static GenericArrayType arrayOf(Type componentType)
Returns an array type whose elements are all instances ofcomponentType.- Returns:
- a
serializablegeneric array type.
-
subtypeOf
public static WildcardType subtypeOf(Type bound)
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
public static WildcardType supertypeOf(Type bound)
Returns a type that represents an unknown supertype ofbound. For example, ifboundisString.class, this returns? super String.
-
canonicalize
public static Type canonicalize(Type type)
Returns a type that is functionally equal but not necessarily equal according toObject.equals(). The returned type isSerializable.
-
getArrayComponentType
public static Type getArrayComponentType(Type array)
Returns the component type of this array type.- Throws:
ClassCastException- if this type is not an array.
-
getCollectionElementType
public static Type getCollectionElementType(Type context, Class<?> contextRawType)
Returns the element type of this collection type.- Throws:
IllegalArgumentException- if this type is not a collection.
-
getMapKeyAndValueTypes
public 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.
-
-