Java Stream of stream(Collection collection)

Here you can find the source of stream(Collection collection)

Description

stream

License

Apache License

Declaration

public static <T> Stream<T> stream(Collection<T> collection) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Collection;
import java.util.Collections;

import java.util.Optional;

import java.util.stream.Stream;

public class Main {
    public static <T> Stream<T> stream(Collection<T> collection) {
        return Optional.ofNullable(collection).orElseGet(Collections::emptyList).stream();
    }//from  w w  w . j  a v  a  2  s . co  m
}

Related

  1. stream(Class clazz)
  2. stream(Enumeration enumeration)
  3. stream(final Iterator iterator)
  4. stream(Iterable iterable)
  5. stream(Iterable input)