A collection of pipes used to transform streams including: filter, sort, map, flatMap...
- Since:
- 1.2
- Author:
- Jeremy Kuhn
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> StreamPipe
<T, T> distinct()
Returns a pipe which converts a stream to filter out duplicates.static <T,
U> StreamPipe <T, T> Returns a pipe which converts a stream to filter out elements based on their keys computed using the specified key selector that do not pass the specified predicate test.static <T> StreamPipe
<T, T> Returns a pipe which converts a stream to filter out elements that do not pass the specified predicate test.static <T,
R> StreamPipe <T, R> Returns a pipe which transforms the elements of the stream into streams by applying the specified mapper function, then flatten these inner stream into a single stream sequentially using concatenation.static <T,
R> StreamPipe <T, R> Returns a pipe which transforms the elements of a stream by applying the specified mapper function.static <T> StreamPipe
<T, T> sort()
Returns a pipe which converts a stream to sort the elements in natural order.static <T> StreamPipe
<T, T> sort
(Comparator<? super T> comparator) Returns a pipe which converts a stream to sort the elements using the specified comparator.
-
Constructor Details
-
StreamPipes
public StreamPipes()
-
-
Method Details
-
distinct
Returns a pipe which converts a stream to filter out duplicates.
- Type Parameters:
T
- the type of element in the stream- Returns:
- a stream pipe
-
sort
Returns a pipe which converts a stream to sort the elements in natural order.
- Type Parameters:
T
- the type of element in the stream- Returns:
- a stream pipe
-
sort
Returns a pipe which converts a stream to sort the elements using the specified comparator.
- Type Parameters:
T
- the type of element in the stream- Parameters:
comparator
- a comparator- Returns:
- a stream pipe
-
filter
Returns a pipe which converts a stream to filter out elements that do not pass the specified predicate test.
- Type Parameters:
T
- the type of element in the stream- Parameters:
predicate
- a predicate- Returns:
- a stream pipe
-
filter
public static <T,U> StreamPipe<T,T> filter(Function<? super T, ? extends U> keySelector, Predicate<? super U> predicate) Returns a pipe which converts a stream to filter out elements based on their keys computed using the specified key selector that do not pass the specified predicate test.
- Type Parameters:
T
- the type of element in the streamU
- the type of the computed keys- Parameters:
keySelector
- a key selectorpredicate
- a predicate- Returns:
- a stream pipe
-
map
Returns a pipe which transforms the elements of a stream by applying the specified mapper function.
- Type Parameters:
T
- the type of element in the streamR
- the type of element in the resulting stream- Parameters:
mapper
- a mapper function- Returns:
- a stream pipe
-
flatMap
public static <T,R> StreamPipe<T,R> flatMap(Function<? super T, ? extends Stream<? extends R>> mapper) Returns a pipe which transforms the elements of the stream into streams by applying the specified mapper function, then flatten these inner stream into a single stream sequentially using concatenation.
- Type Parameters:
T
- the type of element in the publisherR
- the type of element in the resulting publisher- Parameters:
mapper
- a mapper function- Returns:
- a stream pipe
-