Package com.google.gson.internal
Class $Gson$Types
java.lang.Object
com.google.gson.internal.$Gson$Types
Static methods for working with types.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classprivate static final classprivate static final classThe WildcardType interface supports multiple upper bounds and multiple lower bounds. -
Field Summary
Fields -
Constructor Summary
Constructors -
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().(package private) static voidcheckNotPrimitive(Type type) private static Class<?>declaringClassOf(TypeVariable<?> typeVariable) Returns the declaring class oftypeVariable, ornullif it was not declared by a class.(package private) static booleanstatic 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.(package private) static TypegetGenericSupertype(Type context, Class<?> rawType, Class<?> toResolve) Returns the generic supertype forsupertype.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) (package private) static TypegetSupertype(Type context, Class<?> contextRawType, Class<?> supertype) Returns the generic form ofsupertype.(package private) static intprivate static intstatic ParameterizedTypenewParameterizedTypeWithOwner(Type ownerType, Type rawType, Type... typeArguments) Returns a new parameterized type, applyingtypeArgumentstorawTypeand enclosed byownerType.static Typeprivate static Typeresolve(Type context, Class<?> contextRawType, Type toResolve, Map<TypeVariable<?>, Type> visitedTypeVariables) (package private) static TyperesolveTypeVariable(Type context, Class<?> contextRawType, TypeVariable<?> unknown) static 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)
-
Field Details
-
EMPTY_TYPE_ARRAY
-
-
Constructor Details
-
$Gson$Types
private $Gson$Types()
-
-
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
-
equal
-
equals
Returns true ifaandbare equal. -
hashCodeOrZero
-
typeToString
-
getGenericSupertype
Returns the generic supertype forsupertype. For example, given a classIntegerSet, the result for when supertype isSet.classisSet<Integer>and the result when the supertype isCollection.classisCollection<Integer>. -
getSupertype
Returns the generic form ofsupertype. For example, if this isArrayList<String>, this returnsIterable<String>given the inputIterable.class.- Parameters:
supertype- a superclass of, or interface implemented by, this.
-
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
-
resolve
-
resolveTypeVariable
-
indexOf
-
declaringClassOf
Returns the declaring class oftypeVariable, ornullif it was not declared by a class. -
checkNotPrimitive
-