ClassUtils { public static boolean isAssignableFrom(Class<?> toClass, @Nullable Object fromObject) { return fromObject != null && isAssignableFrom(toClass, fromObject.getClass()); } private  ClassUtils(); static Class<?> getNonPrimitiveClass(Class<?> clazz); static Option<Class<?>> selectMostRelated(Collection<? extends Class<?>> classes, Class<?> to); static boolean isAssignableFrom(Class<?> toClass, @Nullable Object fromObject); static boolean isAssignableFrom(@Nullable Class<?> toClass, @Nullable Class<?> fromClass); static Class<?>[] getClasses(Object... values); static boolean exists(String name); @SuppressWarnings("unchecked") static Option<Class<? extends T>> forName(String name); static final Map<Class<?>, Class<?>> PRIMITIVE_EQUIVALENT; }
@Test void isAssignableFrom() { Assertions.assertTrue(ClassUtils.isAssignableFrom(int.class, int.class)); Assertions.assertTrue(ClassUtils.isAssignableFrom(int.class, Integer.class)); Assertions.assertTrue(ClassUtils.isAssignableFrom(Integer.class, int.class)); Assertions.assertFalse(ClassUtils.isAssignableFrom(int.class, Number.class)); Assertions.assertTrue(ClassUtils.isAssignableFrom(Number.class, int.class)); Assertions.assertFalse(ClassUtils.isAssignableFrom(int.class, String.class)); }