@CheckReturnValue
public final class Primitives
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.util.Set<java.lang.Class<?>> |
allPrimitiveTypes()
Returns an immutable set of all nine primitive types (including
void). |
static java.util.Set<java.lang.Class<?>> |
allWrapperTypes()
Returns an immutable set of all nine primitive-wrapper types (including
Void). |
static boolean |
isWrapperType(java.lang.Class<?> type)
Returns
true if type is one of the nine
primitive-wrapper types, such as Integer. |
static <T> java.lang.Class<T> |
unwrap(java.lang.Class<T> type)
Returns the corresponding primitive type of
type if it is a
wrapper type; otherwise returns type itself. |
static <T> java.lang.Class<T> |
wrap(java.lang.Class<T> type)
Returns the corresponding wrapper type of
type if it is a primitive
type; otherwise returns type itself. |
public static java.util.Set<java.lang.Class<?>> allPrimitiveTypes()
void). Note that a simpler way to test whether a Class instance
is a member of this set is to call Class.isPrimitive().public static java.util.Set<java.lang.Class<?>> allWrapperTypes()
Void).public static boolean isWrapperType(java.lang.Class<?> type)
true if type is one of the nine
primitive-wrapper types, such as Integer.Class.isPrimitive()public static <T> java.lang.Class<T> wrap(java.lang.Class<T> type)
type if it is a primitive
type; otherwise returns type itself. Idempotent.
wrap(int.class) == Integer.class
wrap(Integer.class) == Integer.class
wrap(String.class) == String.class
public static <T> java.lang.Class<T> unwrap(java.lang.Class<T> type)
type if it is a
wrapper type; otherwise returns type itself. Idempotent.
unwrap(Integer.class) == int.class
unwrap(int.class) == int.class
unwrap(String.class) == String.class