What is the best/idiomatic way of doing a null check before getting a stream?
I have method that is receiving a List that might be null. So I can\'t jus
List
Java 8:
Optional.ofNullable(collection) .stream() .flatMap(Collection::stream)
Java 9:
Stream.ofNullable(collection) .flatMap(Collection::stream)
Apache Commons Collections 4:
import org.apache.commons.collections4.CollectionUtils; CollectionUtils.emptyIfNull(collection) .stream()