Here you can find the source of optionalToStream(final Optional
public final static <T> Stream<T> optionalToStream(final Optional<T> optional)
//package com.java2s; //License from project: Apache License import java.util.Optional; import java.util.stream.Stream; public class Main { public final static <T> Stream<T> optionalToStream(final Optional<T> optional) { if (optional.isPresent()) return Stream.of(optional.get()); return Stream.of(); }//from w w w .jav a 2 s .c o m }