public final class Primitives extends Object
Modifier and Type | Method and Description |
---|---|
static Set |
allPrimitiveTypes()
Returns an immutable set of all nine primitive types (including
void ).
|
static Set |
allWrapperTypes()
Returns an immutable set of all nine primitive-wrapper types (including
Void ).
|
static boolean |
isWrapperType(Class
|
static <T> Class |
unwrap(Class
Returns the corresponding primitive type of
type if it is a wrapper type; otherwise returns
type itself.
|
static <T> Class |
wrap(Class
Returns the corresponding wrapper type of
type if it is a primitive type; otherwise returns
type itself.
|
public static Set<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 Set<Class <?>> allWrapperTypes()
Void
).
public static boolean isWrapperType(Class<?> type)
Class.isPrimitive()
public static <T> Class<T> wrap(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