Here you can find the source of streamOrEmpty(Iterable
public static <Any> Stream<Any> streamOrEmpty(Iterable<Any> iterable)
//package com.java2s; //License from project: Open Source License import java.util.stream.Stream; import java.util.stream.StreamSupport; public class Main { public static <Any> Stream<Any> streamOrEmpty(Iterable<Any> iterable) { return iterable != null ? StreamSupport.stream(iterable.spliterator(), false) : Stream.empty(); }/* w w w.j a v a 2 s .c om*/ public static <Any> Stream<Any> streamOrEmpty(Stream<Any> stream) { return stream != null ? stream : Stream.empty(); } }