Java Stream Operation optionalToStream(final Optional optional)

Here you can find the source of optionalToStream(final Optional optional)

Description

optional To Stream

License

Apache License

Declaration

public final static <T> Stream<T> optionalToStream(final Optional<T> optional) 

Method Source Code

//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
}

Related

  1. maxStringLength(Stream stringStream)
  2. mkString(Stream items, String prefix, String delimiter, String suffix)
  3. nullableStreamOf(Collection nullableCollection)
  4. ofType(Stream stream, Class type)
  5. opt2stream(Optional opt)
  6. optionalToStream(Optional optional)
  7. orStream(Stream> stream)
  8. parallelStreamFromIterable(Iterable in)
  9. prepend(final T first, final Stream rest)