Here you can find the source of convertPrimitiveToWrapper(Class> clazz)
Parameter | Description |
---|---|
clazz | the class to convert |
public static Class<?> convertPrimitiveToWrapper(Class<?> clazz)
//package com.java2s; import java.util.HashMap; import java.util.Map; public class Main { private static final Map<String, Class<?>> primitiveWrapperClasses = new HashMap<String, Class<?>>(); /**// ww w . ja va 2 s .com * Checks whether a given class object is a primitive and returns its * wrapper class (except for void where always the primitive class is used). * If the class is no primitive the class will be returned without changes. * * @param clazz the class to convert * @return the wrapper class */ public static Class<?> convertPrimitiveToWrapper(Class<?> clazz) { Class<?> result = clazz; if (clazz.isPrimitive()) { // if (clazz.getName().equals("boolean")) { // result = Boolean.class; // } else if (clazz.getName().equals("short")) { // result = Short.class; // } else if (clazz.getName().equals("int")) { // result = Integer.class; // } else if (clazz.getName().equals("long")) { // result = Long.class; // } else if (clazz.getName().equals("float")) { // result = Float.class; // } else if (clazz.getName().equals("double")) { // result = Double.class; // } else if (clazz.getName().equals("byte")) { // result = Byte.class; // } else if (clazz.getName().equals("char")) { // result = Character.class; // } return primitiveWrapperClasses.get(clazz.getName()); } return result; } }