ClassUtils { public static Class<?> getBoxedClass(Class<?> type) { if (type == boolean.class) { return Boolean.class; } else if (type == char.class) { return Character.class; } else if (type == byte.class) { return Byte.class; } else if (type == short.class) { return Short.class; } else if (type == int.class) { return Integer.class; } else if (type == long.class) { return Long.class; } else if (type == float.class) { return Float.class; } else if (type == double.class) { return Double.class; } else { return type; } } private  ClassUtils(); static Object newInstance(String name); static Class<?> forName(String[] packages, String className); static Class<?> forName(String className); static Class<?> classForName(String className); static Class<?> getBoxedClass(Class<?> type); static Boolean boxed(boolean v); static Character boxed(char v); static Byte boxed(byte v); static Short boxed(short v); static Integer boxed(int v); static Long boxed(long v); static Float boxed(float v); static Double boxed(double v); static Object boxed(Object v); static boolean unboxed(Boolean v); static char unboxed(Character v); static byte unboxed(Byte v); static short unboxed(Short v); static int unboxed(Integer v); static long unboxed(Long v); static float unboxed(Float v); static double unboxed(Double v); static Object unboxed(Object v); static boolean isNotEmpty(Object object); static int getSize(Object object); static URI toURI(String name); static Class<?> getGenericClass(Class<?> cls); static Class<?> getGenericClass(Class<?> cls, int i); static boolean isBeforeJava5(String javaVersion); static boolean isBeforeJava6(String javaVersion); static String toString(Throwable e); static void checkBytecode(String name, byte[] bytecode); static String getSizeMethod(Class<?> cls); static String getMethodName(Method method, Class<?>[] parameterClasses, String rightCode); static Method searchMethod(Class<?> currentClass, String name, Class<?>[] parameterTypes); static String getInitCode(Class<?> type); static Map<K, V> toMap(Map.Entry<K, V>[] entries); static String getSimpleClassName(String qualifiedName); static final String CLASS_EXTENSION; static final String JAVA_EXTENSION; }
@Test public void testGetBoxedClass() { Assertions.assertEquals(Boolean.class, ClassUtils.getBoxedClass(boolean.class)); Assertions.assertEquals(Character.class, ClassUtils.getBoxedClass(char.class)); Assertions.assertEquals(Byte.class, ClassUtils.getBoxedClass(byte.class)); Assertions.assertEquals(Short.class, ClassUtils.getBoxedClass(short.class)); Assertions.assertEquals(Integer.class, ClassUtils.getBoxedClass(int.class)); Assertions.assertEquals(Long.class, ClassUtils.getBoxedClass(long.class)); Assertions.assertEquals(Float.class, ClassUtils.getBoxedClass(float.class)); Assertions.assertEquals(Double.class, ClassUtils.getBoxedClass(double.class)); Assertions.assertEquals(ClassUtilsTest.class, ClassUtils.getBoxedClass(ClassUtilsTest.class)); }