ClassUtils { public static Class<?> resolvePrimitiveClassName(String name) { Class<?> result = null; if (name != null && name.length() <= 8) { result = (Class<?>) PRIMITIVE_TYPE_NAME_MAP.get(name); } return result; }  static Class<?> forNameWithThreadContextClassLoader(String name); static Class<?> forNameWithCallerClassLoader(String name, Class<?> caller); static ClassLoader getCallerClassLoader(Class<?> caller); static ClassLoader getClassLoader(Class<?> clazz); static ClassLoader getClassLoader(); static Class<?> forName(String name); static Class<?> forName(String name, ClassLoader classLoader); static Class<?> resolvePrimitiveClassName(String name); static String toShortString(Object obj); static String simpleClassName(Class<?> clazz); static boolean isPrimitive(Class<?> type); static boolean isSimpleType(Class<?> type); static Object convertPrimitive(Class<?> type, String value); static boolean isTypeMatch(Class<?> type, String value); static Set<Class<?>> getAllSuperClasses(Class<?> type, Predicate<Class<?>>... classFilters); static Set<Class<?>> getAllInterfaces(Class<?> type, Predicate<Class<?>>... interfaceFilters); static Set<Class<?>> getAllInheritedTypes(Class<?> type, Predicate<Class<?>>... typeFilters); static boolean isAssignableFrom(Class<?> superType, Class<?> targetType); static boolean isPresent(String className, ClassLoader classLoader); static Class<?> resolveClass(String className, ClassLoader classLoader); static boolean isGenericClass(Class<?> type); static final String ARRAY_SUFFIX; static final Set<Class<?>> SIMPLE_TYPES; }
@Test public void testResolvePrimitiveClassName() throws Exception { assertThat(ClassUtils.resolvePrimitiveClassName("boolean") == boolean.class, is(true)); assertThat(ClassUtils.resolvePrimitiveClassName("byte") == byte.class, is(true)); assertThat(ClassUtils.resolvePrimitiveClassName("char") == char.class, is(true)); assertThat(ClassUtils.resolvePrimitiveClassName("double") == double.class, is(true)); assertThat(ClassUtils.resolvePrimitiveClassName("float") == float.class, is(true)); assertThat(ClassUtils.resolvePrimitiveClassName("int") == int.class, is(true)); assertThat(ClassUtils.resolvePrimitiveClassName("long") == long.class, is(true)); assertThat(ClassUtils.resolvePrimitiveClassName("short") == short.class, is(true)); assertThat(ClassUtils.resolvePrimitiveClassName("[Z") == boolean[].class, is(true)); assertThat(ClassUtils.resolvePrimitiveClassName("[B") == byte[].class, is(true)); assertThat(ClassUtils.resolvePrimitiveClassName("[C") == char[].class, is(true)); assertThat(ClassUtils.resolvePrimitiveClassName("[D") == double[].class, is(true)); assertThat(ClassUtils.resolvePrimitiveClassName("[F") == float[].class, is(true)); assertThat(ClassUtils.resolvePrimitiveClassName("[I") == int[].class, is(true)); assertThat(ClassUtils.resolvePrimitiveClassName("[J") == long[].class, is(true)); assertThat(ClassUtils.resolvePrimitiveClassName("[S") == short[].class, is(true)); }