Here you can find the source of primitiveToWrapper(final Class> cls)
Converts the specified primitive Class object to its corresponding wrapper Class object.
Parameter | Description |
---|---|
cls | the class to convert, may be null |
public static Class<?> primitiveToWrapper(final Class<?> cls)
//package com.java2s; //License from project: Open Source License import java.util.HashMap; import java.util.Map; public class Main { /**/*from w w w . j ava2 s . c o m*/ * Maps primitive {@code Class}es to their corresponding wrapper * {@code Class}. */ private static final Map<Class<?>, Class<?>> primitiveWrapperMap = new HashMap<Class<?>, Class<?>>(); /** * <p> * Converts the specified primitive Class object to its corresponding * wrapper Class object. * </p> * * @param cls * the class to convert, may be null * @return the wrapper class for {@code cls} or {@code cls} if {@code cls} * is not a primitive. {@code null} if null input. */ public static Class<?> primitiveToWrapper(final Class<?> cls) { Class<?> convertedClass = cls; if (cls != null && cls.isPrimitive()) { convertedClass = primitiveWrapperMap.get(cls); } return convertedClass; } }