spring-loaded icon indicating copy to clipboard operation
spring-loaded copied to clipboard

Method Reference throwing null pointer

Open asheshsaraf opened this issue 8 years ago • 0 comments

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 }

asheshsaraf avatar Dec 26 '16 08:12 asheshsaraf