Java Stream of streamOrEmpty(Iterable iterable)

Here you can find the source of streamOrEmpty(Iterable iterable)

Description

stream Or Empty

License

Open Source License

Declaration

public static <Any> Stream<Any> streamOrEmpty(Iterable<Any> iterable) 

Method Source Code

//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();
    }
}

Related

  1. streamOf(Iterable iterable)
  2. streamof(Iterable vals)
  3. streamOf(T value)
  4. streamOfEnumeration(Enumeration e, boolean parallel)
  5. streamOfOptional(Optional element)
  6. streamScanner(Scanner scanner)
  7. streamToList(Stream stream)
  8. toParallelStream(Iterator iter)
  9. toStream(Collection collection)