org.springframework.data.util

## Interface Streamable<T>

All Superinterfaces:
  Iterable<T>, Supplier<Stream<T>>

All Known Subinterfaces:
  Page<T>, PersistentPropertyPath<P>, PersistentPropertyPaths<T,P>, Slice<T>

All Known Implementing Classes:
  DefaultParameters, ExpressionDependencies, GeoPage, PageImpl, Parameters, PartTree, PartTree.OrPart, PersistentEntities, PropertyPath, QSort, RepositoryComposition.RepositoryFragments, Revisions, RevisionSort, SliceImpl, Sort, Sort.TypedSort

Functional Interface:
  This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface Streamable<T>
    extends Iterable<T>, Supplier<Stream<T>>

Simple interface to ease streamability of `Iterable`s.

Since:
  2.0
Author:
  Oliver Gierke, Christoph Strobl

### Method Summary

All Methods Static Methods Instance Methods Default Methods
`default Streamable<T>` `and(Iterable<? extends T> iterable)` Creates a new `Streamable` from the current one and the given `Iterable` concatenated.
`default Streamable<T>` `and(Streamable<? extends T> streamable)` Convenience method to allow adding a `Streamable` directly as otherwise the invocation is ambiguous between `and(Iterable)` and `and(Supplier)`.
`default Streamable<T>` `and(Supplier<? extends Stream<? extends T>> stream)` Creates a new `Streamable` from the current one and the given `Stream` concatenated.
`default Streamable<T>` `and(T... others)` Creates a new `Streamable` from the current one and the given values concatenated.
`static <T> Streamable<T>` `empty()` Returns an empty `Streamable`.
`default Streamable<T>` `filter(Predicate<? super T> predicate)` Returns a new `Streamable` that will apply the given filter `Predicate` to the current one.
`default <R> Streamable<R>` `flatMap(Function<? super T,? extends Stream<? extends R>> mapper)` Returns a new `Streamable` that will apply the given `Function` to the current one.
`default Stream<T>` `get()`
`default boolean` `isEmpty()` Returns whether the current `Streamable` is empty.
`default <R> Streamable<R>` `map(Function<? super T,? extends R> mapper)` Returns a new `Streamable` that will apply the given `Function` to the current one.
`static <T> Streamable<T>` `of(Iterable<T> iterable)` Returns a `Streamable` for the given `Iterable`.
`static <T> Streamable<T>` `of(Supplier<? extends Stream<T>> supplier)`
`static <T> Streamable<T>` `of(T... t)` Returns a `Streamable` with the given elements.
`default Stream<T>` `stream()` Creates a non-parallel `Stream` of the underlying `Iterable`.
`default List<T>` `toList()` Creates a new, unmodifiable `List`.
`default Set<T>` `toSet()` Creates a new, unmodifiable `Set`.
`static <S> Collector<S,?,Streamable<S>>` `toStreamable()` A collector to easily produce a `Streamable` from a `Stream` using `Collectors.toList()` as intermediate collector.
`static <S,T extends Iterable<S>> Collector<S,?,Streamable<S>>` `toStreamable(Collector<S,?,T> intermediate)` A collector to easily produce a `Streamable` from a `Stream` and the given intermediate collector.

### Methods inherited from interface java.lang.Iterable

`forEach, iterator, spliterator`

### Method Detail

#### empty

    static <T> Streamable<T> empty()

Returns an empty `Streamable`.

Returns:
  will never be null.

#### of

    @SafeVarargs
    static <T> Streamable<T> of(T... t)

Returns a `Streamable` with the given elements.

Parameters:
  `t` - the elements to return.
Returns:

#### of

    static <T> Streamable<T> of(Iterable<T> iterable)

Returns a `Streamable` for the given `Iterable`.

Parameters:
  `iterable` - must not be null.
Returns:

#### of

    static <T> Streamable<T> of(Supplier<? extends Stream<T>> supplier)

#### stream

    default Stream<T> stream()

Creates a non-parallel `Stream` of the underlying `Iterable`.

Returns:
  will never be null.

#### map

    default <R> Streamable<R> map(Function<? super T,? extends R> mapper)

Returns a new `Streamable` that will apply the given `Function` to the current one.

Parameters:
  `mapper` - must not be null.
Returns:
See Also:
  `Stream.map(Function)`

#### flatMap

    default <R> Streamable<R> flatMap(Function<? super T,? extends Stream<? extends R>> mapper)

Returns a new `Streamable` that will apply the given `Function` to the current one.

Parameters:
  `mapper` - must not be null.
Returns:
See Also:
  `Stream.flatMap(Function)`

#### filter

    default Streamable<T> filter(Predicate<? super T> predicate)

Returns a new `Streamable` that will apply the given filter `Predicate` to the current one.

Parameters:
  `predicate` - must not be null.
Returns:
See Also:
  `Stream.filter(Predicate)`

#### isEmpty

    default boolean isEmpty()

Returns whether the current `Streamable` is empty.

Returns:

#### and

    default Streamable<T> and(Supplier<? extends Stream<? extends T>> stream)

Creates a new `Streamable` from the current one and the given `Stream` concatenated.

Parameters:
  `stream` - must not be null.
Returns:
Since:
  2.1

#### and

    default Streamable<T> and(T... others)

Creates a new `Streamable` from the current one and the given values concatenated.

Parameters:
  `others` - must not be null.
Returns:
  will never be null.
Since:
  2.2

#### and

    default Streamable<T> and(Iterable<? extends T> iterable)

Creates a new `Streamable` from the current one and the given `Iterable` concatenated.

Parameters:
  `iterable` - must not be null.
Returns:
  will never be null.
Since:
  2.2

#### and

    default Streamable<T> and(Streamable<? extends T> streamable)

Convenience method to allow adding a `Streamable` directly as otherwise the invocation is ambiguous between `and(Iterable)` and `and(Supplier)`.

Parameters:
  `streamable` - must not be null.
Returns:
  will never be null.
Since:
  2.2

#### toList

    default List<T> toList()

Creates a new, unmodifiable `List`.

Returns:
  will never be null.
Since:
  2.2

#### toSet

    default Set<T> toSet()

Creates a new, unmodifiable `Set`.

Returns:
  will never be null.
Since:
  2.2

#### get

    default Stream<T> get()

Specified by:
  `get` in interface `Supplier<Stream<T>>`

#### toStreamable

    static <S> Collector<S,?,Streamable<S>> toStreamable()

A collector to easily produce a `Streamable` from a `Stream` using `Collectors.toList()` as intermediate collector.

Returns:
Since:
  2.2
See Also:
  `toStreamable(Collector)`

#### toStreamable

    static <S,T extends Iterable<S>> Collector<S,?,Streamable<S>> toStreamable(Collector<S,?,T> intermediate)

A collector to easily produce a `Streamable` from a `Stream` and the given intermediate collector.

Returns:
Since:
  2.2