Package org.springframework.data.util
Interface Streamable<T>
- All Known Subinterfaces:
Page<T>,PersistentPropertyPath<P>,PersistentPropertyPaths<T,,P> PropertyPath,Slice<T>,Window<T>
- All Known Implementing Classes:
DefaultParameters,EntityProjection,EntityProjection.ContainerPropertyProjection,EntityProjection.PropertyProjection,ExpressionDependencies,GeoPage,PageImpl,Parameters,PartTree,PartTree.OrPart,PersistentEntities,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
Iterables.- Since:
- 2.0
- Author:
- Oliver Gierke, Christoph Strobl
-
Method Summary
Modifier and TypeMethodDescriptiondefault Streamable<T>Creates a newStreamablefrom the current one and the givenIterableconcatenated.default Streamable<T>Creates a newStreamablefrom the current one and the givenStreamconcatenated.default Streamable<T>and(Streamable<? extends T> streamable) Convenience method to allow adding aStreamabledirectly as otherwise the invocation is ambiguous betweenand(Iterable)andand(Supplier).default Streamable<T>Creates a newStreamablefrom the current one and the given values concatenated.static <T> Streamable<T>empty()Returns an emptyStreamable.default Streamable<T>Returns a newStreamablethat will apply the given filterPredicateto the current one.default <R> Streamable<R>Returns a newStreamablethat will apply the givenFunctionto the current one.get()default booleanisEmpty()Returns whether the currentStreamableis empty.default <R> Streamable<R>Returns a newStreamablethat will apply the givenFunctionto the current one.static <T> Streamable<T>Returns aStreamablefor the givenIterable.static <T> Streamable<T>static <T> Streamable<T>of(T... t) Returns aStreamablewith 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 aStreamablefrom aStreamusingCollectors.toList()as intermediate collector.static <S,T extends Iterable<S>>
Collector<S,?, Streamable<S>> toStreamable(Collector<S, ?, T> intermediate) A collector to easily produce aStreamablefrom aStreamand 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 aStreamablewith the given elements.- Parameters:
t- the elements to return.- Returns:
-
of
Returns aStreamablefor the givenIterable.- Parameters:
iterable- must not be null.- Returns:
-
of
-
stream
- Returns:
- will never be null.
-
map
Returns a newStreamablethat will apply the givenFunctionto the current one.- Parameters:
mapper- must not be null.- Returns:
- See Also:
-
flatMap
Returns a newStreamablethat will apply the givenFunctionto the current one.- Parameters:
mapper- must not be null.- Returns:
- See Also:
-
filter
Returns a newStreamablethat will apply the given filterPredicateto the current one.- Parameters:
predicate- must not be null.- Returns:
- See Also:
-
isEmpty
default boolean isEmpty()Returns whether the currentStreamableis empty.- Returns:
-
and
Creates a newStreamablefrom the current one and the givenStreamconcatenated.- Parameters:
stream- must not be null.- Returns:
- Since:
- 2.1
-
and
Creates a newStreamablefrom 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 newStreamablefrom the current one and the givenIterableconcatenated.- Parameters:
iterable- must not be null.- Returns:
- will never be null.
- Since:
- 2.2
-
and
Convenience method to allow adding aStreamabledirectly 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 aStreamablefrom aStreamusingCollectors.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 aStreamablefrom aStreamand the given intermediate collector.- Returns:
- Since:
- 2.2
-