spring-loaded
spring-loaded copied to clipboard
Method Reference throwing null pointer
public static <T, Z> T getIfNotNull(final Z object, final Supplier<T> objectValue) { return object == null ? null : objectValue.get(); }
@Test public void test() { final String id = null; MatcherAssert.assertThat(ConditionalOperation.getIfNotNull(id, () -> id.toString()) == null, Is.is(true)); // working MatcherAssert.assertThat(ConditionalOperation.getIfNotNull(id, id::toString) == null, Is.is(true)); // not working }