Java Utililty Methods Class to Primitive

List of utility methods to do Class to Primitive

Description

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

Method

ClassgetPrimitiveClass(String name)
get Primitive Class
if (name.length() <= PRIMITIVE_CLASS_NAME_MAX_LENGTH) {
    int index = Arrays.binarySearch(PRIMITIVE_NAMES, name);
    if (index >= 0) {
        return PRIMITIVE_CLASSES[index];
return null;
ObjectgetPrimitiveDftValue(Class clazz)
get Primitive Dft Value
return primitiveTypeDftValueMap.get(clazz);
ClassgetPrimitiveTypeByWrapper(Class clazz)
get Primitive Type By Wrapper
return wrapperPrimitiveTypeMap.get(clazz);
ClassgetPrimitiveWrapper(Class c)
If the specified class is a primitive (e.g.
return pmap1.get(c);
ClassgetWrapper(String primitiveClassName)
get Wrapper
return primitiveTypeMap.get(primitiveClassName);
ClassgetWrapperTypeByPrimitive(Class clazz)
get Wrapper Type By Primitive
return primitiveWrapperTypeMap.get(clazz);
ClassprimitiveToWrapper(Class cls)

Converts the specified primitive Class object to its corresponding wrapper Class object.

Class convertedClass = cls;
if (cls != null && cls.isPrimitive())
    convertedClass = (Class) primitiveWrapperMap.get(cls);
return convertedClass;
ClassprimitiveToWrapper(Class in)
convert the input class to a wrapper class returns in if the argument is not primitive
if (!in.isPrimitive())
    return (in);
if (gPrimitiveClassToWrapper == null)
    buildWrapperMapping();
return ((Class) gPrimitiveClassToWrapper.get(in));
ClassprimitiveToWrapper(final Class p)
Returns referenced wrapper for primitive type.
return PRIMITIVES_TO_WRAPPERS.get(p);
ClasstoClass(String primitiveName)
Convert a primitive name (int, byte etc.) to a class or null if the name is not a primitive.
return (Class) PRIMITIVE_NAME_MAP.get(primitiveName);