I was reading an article linked from a slashdot story, and came across this little tidbit:
Take the latest version of Java, which tries to make null-poi
There you have it, null-safe invocation in Java 8:
public void someMethod() { String userName = nullIfAbsent(new Order(), t -> t.getAccount().getUser() .getName()); } static R nullIfAbsent(T t, Function funct) { try { return funct.apply(t); } catch (NullPointerException e) { return null; } }