public class Primitives
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.util.Map<java.lang.Class<?>,java.lang.Object> |
PRIMITIVE_OR_WRAPPER_DEFAULT_VALUES |
private static java.util.Map<java.lang.Class<?>,java.lang.Class<?>> |
PRIMITIVE_TYPES |
Constructor and Description |
---|
Primitives() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
defaultValue(java.lang.Class<T> primitiveOrWrapperType)
Returns the boxed default value for a primitive or a primitive wrapper.
|
static boolean |
isAssignableFromWrapper(java.lang.Class<?> valueClass,
java.lang.Class<?> referenceType) |
static boolean |
isPrimitiveOrWrapper(java.lang.Class<?> type)
Indicates if the given class is primitive type or a primitive wrapper.
|
static <T> java.lang.Class<T> |
primitiveTypeOf(java.lang.Class<T> clazz)
Returns the primitive type of the given class.
|
private static final java.util.Map<java.lang.Class<?>,java.lang.Class<?>> PRIMITIVE_TYPES
private static final java.util.Map<java.lang.Class<?>,java.lang.Object> PRIMITIVE_OR_WRAPPER_DEFAULT_VALUES
public static <T> java.lang.Class<T> primitiveTypeOf(java.lang.Class<T> clazz)
boolean.class
, Integer.class
in witch case this method will return boolean.class
, even SomeObject.class
in which case null
will be returned.T
- The typeclazz
- The class from which primitive type has to be retrievednull
public static boolean isPrimitiveOrWrapper(java.lang.Class<?> type)
type
- The type to checktrue
if primitive or wrapper, false
otherwise.public static boolean isAssignableFromWrapper(java.lang.Class<?> valueClass, java.lang.Class<?> referenceType)
public static <T> T defaultValue(java.lang.Class<T> primitiveOrWrapperType)
primitiveOrWrapperType
- The type to lookup the default valuenull
if the type is neither a primitive nor a wrapper