public class Primitives
extends java.lang.Object
Constructor and Description |
---|
Primitives() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
defaultValueForPrimitiveOrWrapper(java.lang.Class<T> primitiveOrWrapperType)
Returns the boxed default value for a primitive or a primitive wrapper.
|
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.
|
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 <T> T defaultValueForPrimitiveOrWrapper(java.lang.Class<T> primitiveOrWrapperType)
primitiveOrWrapperType
- The type to lookup the default valuenull
if the type is neither a primitive nor a wrapper