Package org.codice.gsonsupport
Class GsonTypes
java.lang.Object
org.codice.gsonsupport.GsonTypes
Static methods for working with types.
Note: This File has been copied from Gson's invalid input: '<'a
href="https://github.com/google/gson/blob/master/gson/src/main/java/com/google/gson/internal/$Gson$Types.java"
$Gson$Types class with the only changes being
The import was required because the source class resides in an `internal` package and was
therefore not exported by the OSGi bundle.checkNotNull(Object) and checkArgument(boolean) methods from
the $Gson$Preconditions class to reduce complexity
- 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 voidcheckArgument(boolean condition) static <T> TcheckNotNull(T obj) 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
-
checkNotNull
public static <T> T checkNotNull(T obj) -
checkArgument
public static void checkArgument(boolean condition) -
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
Returns true ifaandbare 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
-