Here you can find the source of toPrimitiveType(Class> c)
public static Class<?> toPrimitiveType(Class<?> c)
//package com.java2s; public class Main { public static Class<?> toPrimitiveType(Class<?> c) { if (c == null || c.isPrimitive()) return c; // In descending order of likelihood... if (c.equals(Void.class)) return c; else if (c.equals(Boolean.class)) return Boolean.TYPE; else if (c.equals(Integer.class)) return Integer.TYPE; else if (c.equals(Double.class)) return Double.TYPE; else if (c.equals(Long.class)) return Long.TYPE; else if (c.equals(Character.class)) return Character.TYPE; else if (c.equals(Byte.class)) return Byte.TYPE; else if (c.equals(Short.class)) return Short.TYPE; else if (c.equals(Float.class)) return Float.TYPE; else {//from w ww .j a va 2s.c om assert false : "It seems a new-fangled primitive type has been invented called " + c.getName(); return c; } } /** * Returns true if obj1 and obj2 are both null, or if obj1.equals(obj2). Else returns false. * * @param obj1 * @param obj2 * @return boolean */ public static boolean equals(Object obj1, Object obj2) { if (obj1 == obj2) return true; if (obj1 == null || obj2 == null) return false; return obj1.equals(obj2); } }