Java Utililty Methods Primitive Type Create

List of utility methods to do Primitive Type Create

Description

The list of methods to do Primitive Type Create are organized into topic(s).

Method

ClasstoPrimitiveType(Class c)
to Primitive Type
if (c == null || c.isPrimitive())
    return c;
if (c.equals(Void.class))
    return c;
else if (c.equals(Boolean.class))
    return Boolean.TYPE;
else if (c.equals(Integer.class))
    return Integer.TYPE;
...
ClasstoPrimitiveType(Class cls)
to Primitive Type
Class<?> pType = cls;
if (!cls.isArray()) {
    if (Boolean.TYPE == cls)
        pType = Boolean.class;
    else if (Character.TYPE == cls)
        pType = Character.class;
    else if (Byte.TYPE == cls)
        pType = Byte.class;
...
ClasstoPrimitiveType(Class type)
to Primitive Type
if (type == Boolean.class)
    return Boolean.TYPE;
else if (type == Byte.class)
    return Byte.TYPE;
else if (type == Short.class)
    return Short.TYPE;
else if (type == Integer.class)
    return Integer.TYPE;
...
ClasstoPrimitiveWrapper(Class type)
to Primitive Wrapper
if (type.equals(boolean.class)) {
    return Boolean.class;
} else if (type.equals(byte.class)) {
    return Byte.class;
} else if (type.equals(char.class)) {
    return Character.class;
} else if (type.equals(short.class)) {
    return Short.class;
...
TtoPrimitiveWrapper(String primitiveJson, Class clazz)
to Primitive Wrapper
Object result = null;
if (clazz.isAssignableFrom(Integer.class)) {
    result = Integer.valueOf(primitiveJson);
} else if (clazz.isAssignableFrom(Long.class)) {
    result = Long.valueOf(primitiveJson);
} else if (clazz.isAssignableFrom(Short.class)) {
    result = Short.valueOf(primitiveJson);
} else if (clazz.isAssignableFrom(Float.class)) {
...