Idiomatic way to create a Stream from a Nullable object
I agree with Stuart Marks that list == null ? Stream.empty() : list.stream() is the right way to do this (see his answer), or at least the right way to do this pre-Java 9 (see edit below), but I’ll leave this answer up to demonstrate usage of the Optional API. <T> Stream<T> getStream(List<T> list) { … Read more