Say I have the following code
data.stream() .map(x -> { Object a = maybeReturnsNull(x); return a == null ? defaultValue : a; }) >
java has provided a dedicated API to handle with "null".
https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html