public class

MoreStreams

extends Object
java.lang.Object
   ↳ com.atlassian.bitbucket.util.MoreStreams

Class Overview

Additional utilities for creating Stream streams.

Summary

Public Methods
@Nonnull static <T> Iterable<T> asIterable(Stream<T> stream)
Returns the Stream as an Iterable.
@Nonnull static <T> Stream<T> streamEnumeration(Enumeration<T> enumeration)
Converts an Enumeration to a Stream.
@Nonnull static <T> Stream<T> streamIterable(Iterable<T> iterable)
Converts an Iterable to a Stream.
@Nonnull static <T> Stream<T> streamOptional(Optional<T> optional)
Converts an Optional to a single-element or empty Stream.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

@Nonnull public static Iterable<T> asIterable (Stream<T> stream)

Returns the Stream as an Iterable.

Note: the returned Iterable can only be iterated once.

Parameters
stream the stream
Returns
  • the Stream as an Iterable

@Nonnull public static Stream<T> streamEnumeration (Enumeration<T> enumeration)

Converts an Enumeration to a Stream.

Parameters
enumeration the Enumeration to stream
Returns
  • a Stream over the provided enumeration
Throws
NullPointerException if the provided enumeration is null

@Nonnull public static Stream<T> streamIterable (Iterable<T> iterable)

Converts an Iterable to a Stream.

Parameters
iterable the Iterable to stream
Returns
  • a Stream over the provided iterable
Throws
NullPointerException if the provided iterable is null

@Nonnull public static Stream<T> streamOptional (Optional<T> optional)

Converts an Optional to a single-element or empty Stream.

Parameters
optional the Optional to stream
Returns
  • a single-element Stream if the Optional is present; otherwise an empty Stream
Throws
NullPointerException if the provided optional is null