@Test void forName() { Assertions.assertTrue(ClassUtils.forName(String.class.getName()).isPresent()); Assertions.assertFalse(ClassUtils.forName("xyz").isPresent()); }
@SuppressWarnings("unchecked") public static <T> Option<Class<? extends T>> forName(String name) { try { Class<T> clazz = (Class<T>) Class.forName(name); return Option.of(clazz); } catch (ClassNotFoundException e) { return Option.none(); } }
ClassUtils { @SuppressWarnings("unchecked") public static <T> Option<Class<? extends T>> forName(String name) { try { Class<T> clazz = (Class<T>) Class.forName(name); return Option.of(clazz); } catch (ClassNotFoundException e) { return Option.none(); } } }
ClassUtils { @SuppressWarnings("unchecked") public static <T> Option<Class<? extends T>> forName(String name) { try { Class<T> clazz = (Class<T>) Class.forName(name); return Option.of(clazz); } catch (ClassNotFoundException e) { return Option.none(); } } private  ClassUtils(); }
ClassUtils { @SuppressWarnings("unchecked") public static <T> Option<Class<? extends T>> forName(String name) { try { Class<T> clazz = (Class<T>) Class.forName(name); return Option.of(clazz); } catch (ClassNotFoundException e) { return Option.none(); } } 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); }
ClassUtils { @SuppressWarnings("unchecked") public static <T> Option<Class<? extends T>> forName(String name) { try { Class<T> clazz = (Class<T>) Class.forName(name); return Option.of(clazz); } catch (ClassNotFoundException e) { return Option.none(); } } 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; }