@Test void cast() { Assertions.assertEquals("text", ObjectUtils.cast("text")); Assertions.assertNull(ObjectUtils.cast(String.class, 5)); Object unknown = "content"; Assertions.assertEquals("content", ObjectUtils.cast(String.class, unknown)); Assertions.assertDoesNotThrow(() -> { @SuppressWarnings("unused") String value = ObjectUtils.cast(null); }); }
public static @Nullable <T> T cast(Class<T> clazz, @Nullable Object object) { if (!clazz.isInstance(object)) { return null; } return clazz.cast(object); }
ObjectUtils { public static @Nullable <T> T cast(Class<T> clazz, @Nullable Object object) { if (!clazz.isInstance(object)) { return null; } return clazz.cast(object); } }
ObjectUtils { public static @Nullable <T> T cast(Class<T> clazz, @Nullable Object object) { if (!clazz.isInstance(object)) { return null; } return clazz.cast(object); } private  ObjectUtils(); }
ObjectUtils { public static @Nullable <T> T cast(Class<T> clazz, @Nullable Object object) { if (!clazz.isInstance(object)) { return null; } return clazz.cast(object); } private  ObjectUtils(); static @Nullable T cast(Class<T> clazz, @Nullable Object object); @SuppressWarnings("unchecked") static @Nullable T cast(Object object); static boolean isNotNull(@Nullable Object object); static boolean areNull(Object... objects); static boolean equalsOneOf(Object value, Object... expected); static boolean equals(T object, C value, Object to, Function<T, C> getter); @SuppressWarnings("unchecked") static boolean equals(T object, Object to, BiPredicate<T, T> equals); }
ObjectUtils { public static @Nullable <T> T cast(Class<T> clazz, @Nullable Object object) { if (!clazz.isInstance(object)) { return null; } return clazz.cast(object); } private  ObjectUtils(); static @Nullable T cast(Class<T> clazz, @Nullable Object object); @SuppressWarnings("unchecked") static @Nullable T cast(Object object); static boolean isNotNull(@Nullable Object object); static boolean areNull(Object... objects); static boolean equalsOneOf(Object value, Object... expected); static boolean equals(T object, C value, Object to, Function<T, C> getter); @SuppressWarnings("unchecked") static boolean equals(T object, Object to, BiPredicate<T, T> equals);  }