Package org.springframework.data.util
Interface Streamable<T>
- All Known Subinterfaces:
Page<T>
,PersistentPropertyPath<P>
,PersistentPropertyPaths<T,
,P> Slice<T>
,Window<T>
- All Known Implementing Classes:
DefaultParameters
,EntityProjection
,EntityProjection.ContainerPropertyProjection
,EntityProjection.PropertyProjection
,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.
Simple interface to ease streamability of
Iterable
s.- Since:
- 2.0
- Author:
- Oliver Gierke, Christoph Strobl
-
Method Summary
Modifier and TypeMethodDescriptiondefault Streamable<T>
Creates a newStreamable
from the current one and the givenIterable
concatenated.default Streamable<T>
Creates a newStreamable
from the current one and the givenStream
concatenated.default Streamable<T>
and
(Streamable<? extends T> streamable) Convenience method to allow adding aStreamable
directly as otherwise the invocation is ambiguous betweenand(Iterable)
andand(Supplier)
.default Streamable<T>
Creates a newStreamable
from the current one and the given values concatenated.static <T> Streamable<T>
empty()
Returns an emptyStreamable
.default Streamable<T>
Returns a newStreamable
that will apply the given filterPredicate
to the current one.default <R> Streamable<R>
Returns a newStreamable
that will apply the givenFunction
to the current one.get()
default boolean
isEmpty()
Returns whether the currentStreamable
is empty.default <R> Streamable<R>
Returns a newStreamable
that will apply the givenFunction
to the current one.static <T> Streamable<T>
Returns aStreamable
for the givenIterable
.static <T> Streamable<T>
static <T> Streamable<T>
of
(T... t) Returns aStreamable
with the given elements.stream()
toList()
Creates a new, unmodifiableList
.toSet()
Creates a new, unmodifiableSet
.static <S> Collector<S,
?, Streamable<S>> A collector to easily produce aStreamable
from aStream
usingCollectors.toList()
as intermediate collector.static <S,
T extends Iterable<S>>
Collector<S,?, Streamable<S>> toStreamable
(Collector<S, ?, T> intermediate) A collector to easily produce aStreamable
from aStream
and the given intermediate collector.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
empty
Returns an emptyStreamable
.- Returns:
- will never be null.
-
of
Returns aStreamable
with the given elements.- Parameters:
t
- the elements to return.- Returns:
-
of
Returns aStreamable
for the givenIterable
.- Parameters:
iterable
- must not be null.- Returns:
-
of
-
stream
- Returns:
- will never be null.
-
map
Returns a newStreamable
that will apply the givenFunction
to the current one.- Parameters:
mapper
- must not be null.- Returns:
- See Also:
-
flatMap
Returns a newStreamable
that will apply the givenFunction
to the current one.- Parameters:
mapper
- must not be null.- Returns:
- See Also:
-
filter
Returns a newStreamable
that will apply the given filterPredicate
to the current one.- Parameters:
predicate
- must not be null.- Returns:
- See Also:
-
isEmpty
default boolean isEmpty()Returns whether the currentStreamable
is empty.- Returns:
-
and
Creates a newStreamable
from the current one and the givenStream
concatenated.- Parameters:
stream
- must not be null.- Returns:
- Since:
- 2.1
-
and
Creates a newStreamable
from the current one and the given values concatenated.- Parameters:
others
- must not be null.- Returns:
- will never be null.
- Since:
- 2.2
-
and
Creates a newStreamable
from the current one and the givenIterable
concatenated.- Parameters:
iterable
- must not be null.- Returns:
- will never be null.
- Since:
- 2.2
-
and
Convenience method to allow adding aStreamable
directly as otherwise the invocation is ambiguous betweenand(Iterable)
andand(Supplier)
.- Parameters:
streamable
- must not be null.- Returns:
- will never be null.
- Since:
- 2.2
-
toList
Creates a new, unmodifiableList
.- Returns:
- will never be null.
- Since:
- 2.2
-
toSet
Creates a new, unmodifiableSet
.- Returns:
- will never be null.
- Since:
- 2.2
-
get
-
toStreamable
A collector to easily produce aStreamable
from aStream
usingCollectors.toList()
as intermediate collector.- Returns:
- Since:
- 2.2
- See Also:
-
toStreamable
static <S,T extends Iterable<S>> Collector<S,?, toStreamableStreamable<S>> (Collector<S, ?, T> intermediate) A collector to easily produce aStreamable
from aStream
and the given intermediate collector.- Returns:
- Since:
- 2.2
-