Package com.google.gson.internal
Class Primitives
- java.lang.Object
-
- com.google.gson.internal.Primitives
-
public final class Primitives extends java.lang.ObjectContains static utility methods pertaining to primitive types and their corresponding wrapper types.
-
-
Constructor Summary
Constructors Modifier Constructor Description privatePrimitives()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisPrimitive(java.lang.reflect.Type type)Returns true if this type is a primitive.static booleanisWrapperType(java.lang.reflect.Type type)Returnstrueiftypeis one of the nine primitive-wrapper types, such asInteger.static <T> java.lang.Class<T>unwrap(java.lang.Class<T> type)Returns the corresponding primitive type oftypeif it is a wrapper type; otherwise returnstypeitself.static <T> java.lang.Class<T>wrap(java.lang.Class<T> type)Returns the corresponding wrapper type oftypeif it is a primitive type; otherwise returnstypeitself.
-
-
-
Method Detail
-
isPrimitive
public static boolean isPrimitive(java.lang.reflect.Type type)
Returns true if this type is a primitive.
-
isWrapperType
public static boolean isWrapperType(java.lang.reflect.Type type)
Returnstrueiftypeis one of the nine primitive-wrapper types, such asInteger.- See Also:
Class.isPrimitive()
-
wrap
public static <T> java.lang.Class<T> wrap(java.lang.Class<T> type)
Returns the corresponding wrapper type oftypeif it is a primitive type; otherwise returnstypeitself. Idempotent.wrap(int.class) == Integer.class wrap(Integer.class) == Integer.class wrap(String.class) == String.class
-
unwrap
public static <T> java.lang.Class<T> unwrap(java.lang.Class<T> type)
Returns the corresponding primitive type oftypeif it is a wrapper type; otherwise returnstypeitself. Idempotent.unwrap(Integer.class) == int.class unwrap(int.class) == int.class unwrap(String.class) == String.class
-
-