Hallo,
kann ich in Java 8 prüfen, ob eine @FunctionalInterface Instanz von einem null Object kommt?
Das Problem ist, wenn ich so eine Instanz habe, tritt eine java.lang.NullPointerException auf, wenn ich deren Funktion aufrufe:
kann ich in Java 8 prüfen, ob eine @FunctionalInterface Instanz von einem null Object kommt?
Das Problem ist, wenn ich so eine Instanz habe, tritt eine java.lang.NullPointerException auf, wenn ich deren Funktion aufrufe:
Java:
@Test
public void testNullObjectMethod() {
Collection<?> collection = null;
Predicate<Collection<?>> predicate = collection::equals;
Assert.assertNotNull(predicate); // OK
Assert.assertTrue(predicate instanceof Predicate<?>); // OK
predicate.test(Collections.EMPTY_LIST); // NPE
}