Java Class to Primitive primitiveToWrapper(final Class p)

Here you can find the source of primitiveToWrapper(final Class p)

Description

Returns referenced wrapper for primitive type.

License

Apache License

Parameter

Parameter Description
p class suppose to be a primitive

Return

wrapper for primitive, null if passed type is not a primitive

Declaration

public static Class<?> primitiveToWrapper(final Class<?> p) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    /**//w w w  . j  a  v  a2  s  .  c o m
     * lookup map for matching primitive types and their object wrappers.
     */
    private static final Map<Class<?>, Class<?>> PRIMITIVES_TO_WRAPPERS = new HashMap<>();

    /**
     * Returns referenced wrapper for primitive type.
     *
     * @param p class suppose to be a primitive
     * @return wrapper for primitive, {@code null} if passed type is not a
     *         primitive
     */
    public static Class<?> primitiveToWrapper(final Class<?> p) {
        return PRIMITIVES_TO_WRAPPERS.get(p);
    }
}

Related

  1. getPrimitiveWrapper(Class c)
  2. getWrapper(String primitiveClassName)
  3. getWrapperTypeByPrimitive(Class clazz)
  4. primitiveToWrapper(Class cls)
  5. primitiveToWrapper(Class in)
  6. toClass(String primitiveName)