
public final class PrimitiveUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
private static Map<Class<?>,Function<Number,? extends Number>> |
NUMBER_CASTER |
private static List<Class<?>> |
PRIMITIVE_LIST |
private static List<Class<?>> |
PRIMITIVE_NUMBER_LIST |
private static List<Class<?>> |
WRAPPER_LIST |
private static List<Class<? extends Number>> |
WRAPPER_NUMBER_LIST |
| Modifier | Constructor and Description |
|---|---|
private |
PrimitiveUtils() |
| Modifier and Type | Method and Description |
|---|---|
static Optional<Number> |
castIfNeeded(Class<?> dest,
Number arg) |
static boolean |
classIsNumber(Class<?> clazz) |
static boolean |
classIsPrimitive(Class<?> clazz) |
static boolean |
classIsWrapper(Class<?> clazz) |
static Class<? extends Number> |
toPrimitiveWrapper(Number n)
Given a
Number, tries to guess at which wrapper-class it may
belong. |
public static boolean classIsWrapper(Class<?> clazz)
clazz - the class under testpublic static boolean classIsPrimitive(Class<?> clazz)
clazz - the class under testpublic static boolean classIsNumber(Class<?> clazz)
clazz - the class under testNumber or it is a
number having primitive representation in Javapublic static Optional<Number> castIfNeeded(Class<?> dest, Number arg)
dest - the desired number classarg - the argument that may need to be cast