public class StreamUtilities
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <A,B> java.util.stream.Collector<java.util.Map.Entry<? extends A,? extends B>,?,java.util.Map<A,B>> |
entriesToMap() |
static boolean |
equals(java.util.stream.Stream<?> first,
java.util.stream.Stream<?> second) |
static <T> java.util.stream.Stream<T> |
flatMapRecursive(java.util.stream.Stream<? extends T> stream,
java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends T>> mapping)
Generate a stream which recursively traverses depth-first over the elements
of some nested data structure starting from those in a given stream.
|
static <T> java.util.stream.Stream<T> |
flatMapRecursive(T root,
java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends T>> mapping)
Generate a stream which recursively traverses depth-first over the elements
of some nested data structure starting from its root.
|
static <T> java.util.stream.Stream<T> |
flatMapRecursiveDistinct(java.util.stream.Stream<? extends T> stream,
java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends T>> mapping)
Generate a stream which recursively traverses depth-first over the elements
of some nested data structure starting from those in a given stream.
|
protected static <T> java.util.stream.Stream<T> |
flatMapRecursiveDistinct(java.util.stream.Stream<? extends T> stream,
java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends T>> mapping,
java.util.Set<T> visited) |
static <T> java.util.stream.Stream<T> |
flatMapRecursiveDistinct(T root,
java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends T>> mapping)
Generate a stream which recursively traverses depth-first over the elements
of some nested data structure starting from its root.
|
static <T> java.util.stream.Stream<T> |
iterate(T root,
java.util.function.Function<? super T,? extends T> mapping)
A bit like
Stream.iterate(Object, UnaryOperator) but not
completely and utterly useless because it actually supports
termination. |
static <T> java.util.stream.Stream<T> |
iterateOptional(java.util.Optional<? extends T> root,
java.util.function.Function<? super T,java.util.Optional<? extends T>> mapping)
A bit like
Stream.iterate(Object, UnaryOperator) but not
completely and utterly useless because it actually supports
termination. |
static <T> java.util.stream.Stream<T> |
iterateOptional(T root,
java.util.function.Function<? super T,java.util.Optional<? extends T>> mapping)
A bit like
Stream.iterate(Object, UnaryOperator) but not
completely and utterly useless because it actually supports
termination. |
static <T> java.util.stream.Stream<T> |
reverse(java.util.stream.Stream<? extends T> stream) |
static <T> java.util.stream.Stream<T> |
streamNullable(T optional) |
static <T> java.util.stream.Stream<T> |
streamOptional(java.util.Optional<? extends T> optional) |
static <T> java.util.function.BinaryOperator<T> |
throwingReduce() |
static <T> java.util.function.BinaryOperator<T> |
throwingReduce(java.util.function.BiFunction<T,T,java.lang.RuntimeException> exception) |
static <T> java.util.function.BinaryOperator<T> |
throwingSerialCombiner() |
static <T> java.util.Optional<T> |
tryOptional(java.util.function.Supplier<T> attempt,
java.util.function.Consumer<? super java.lang.RuntimeException> exceptions) |
static <T> java.util.Optional<T> |
tryOptional(ThrowingSupplier<? extends T,?> attempt) |
static <T,E extends java.lang.Exception> |
tryOptional(ThrowingSupplier<? extends T,E> attempt,
java.util.function.Consumer<? super java.lang.Exception> runtimeExceptions,
java.util.function.Consumer<? super E> checkedExceptions) |
static <T> java.util.Optional<T> |
upcastOptional(java.util.Optional<? extends T> stream) |
static <T> java.util.stream.Stream<T> |
upcastStream(java.util.stream.Stream<? extends T> stream) |
static <A,B> java.util.stream.Stream<java.util.Map.Entry<A,B>> |
zip(java.util.stream.Stream<A> first,
java.util.stream.Stream<B> second) |
static <A,B,R> java.util.stream.Stream<R> |
zip(java.util.stream.Stream<A> first,
java.util.stream.Stream<B> second,
java.util.function.BiFunction<A,B,R> combiner) |
static <A,B,R> java.util.stream.Stream<R> |
zip(java.util.stream.Stream<A> first,
java.util.stream.Stream<B> second,
java.util.function.BiFunction<A,B,R> combiner,
java.util.function.Supplier<java.lang.RuntimeException> mismatchedStreams) |
static <A,B> java.util.stream.Stream<java.util.Map.Entry<A,B>> |
zip(java.util.stream.Stream<A> first,
java.util.stream.Stream<B> second,
java.util.function.Supplier<java.lang.RuntimeException> mismatchedStreams) |
public static <T> java.util.function.BinaryOperator<T> throwingSerialCombiner()
public static <T> java.util.function.BinaryOperator<T> throwingReduce()
public static <T> java.util.function.BinaryOperator<T> throwingReduce(java.util.function.BiFunction<T,T,java.lang.RuntimeException> exception)
public static boolean equals(java.util.stream.Stream<?> first, java.util.stream.Stream<?> second)
public static <T> java.util.stream.Stream<T> upcastStream(java.util.stream.Stream<? extends T> stream)
public static <T> java.util.Optional<T> upcastOptional(java.util.Optional<? extends T> stream)
public static <T> java.util.stream.Stream<T> streamOptional(java.util.Optional<? extends T> optional)
public static <T> java.util.stream.Stream<T> streamNullable(T optional)
public static <T> java.util.Optional<T> tryOptional(ThrowingSupplier<? extends T,?> attempt)
public static <T,E extends java.lang.Exception> java.util.Optional<T> tryOptional(ThrowingSupplier<? extends T,E> attempt, java.util.function.Consumer<? super java.lang.Exception> runtimeExceptions, java.util.function.Consumer<? super E> checkedExceptions)
public static <T> java.util.Optional<T> tryOptional(java.util.function.Supplier<T> attempt, java.util.function.Consumer<? super java.lang.RuntimeException> exceptions)
public static <A,B> java.util.stream.Collector<java.util.Map.Entry<? extends A,? extends B>,?,java.util.Map<A,B>> entriesToMap()
public static <A,B> java.util.stream.Stream<java.util.Map.Entry<A,B>> zip(java.util.stream.Stream<A> first, java.util.stream.Stream<B> second)
public static <A,B> java.util.stream.Stream<java.util.Map.Entry<A,B>> zip(java.util.stream.Stream<A> first, java.util.stream.Stream<B> second, java.util.function.Supplier<java.lang.RuntimeException> mismatchedStreams)
public static <A,B,R> java.util.stream.Stream<R> zip(java.util.stream.Stream<A> first, java.util.stream.Stream<B> second, java.util.function.BiFunction<A,B,R> combiner)
public static <A,B,R> java.util.stream.Stream<R> zip(java.util.stream.Stream<A> first, java.util.stream.Stream<B> second, java.util.function.BiFunction<A,B,R> combiner, java.util.function.Supplier<java.lang.RuntimeException> mismatchedStreams)
public static <T> java.util.stream.Stream<T> reverse(java.util.stream.Stream<? extends T> stream)
T
- the type of the stream elementsstream
- an ordered streampublic static <T> java.util.stream.Stream<T> iterate(T root, java.util.function.Function<? super T,? extends T> mapping)
Stream.iterate(Object, UnaryOperator)
but not
completely and utterly useless because it actually supports
termination.
TODO should hopefully be made redundant by takeWhile in Java 9T
- the type of the stream elementsroot
- the root elementmapping
- a mapping from an element to the next elementpublic static <T> java.util.stream.Stream<T> iterateOptional(T root, java.util.function.Function<? super T,java.util.Optional<? extends T>> mapping)
Stream.iterate(Object, UnaryOperator)
but not
completely and utterly useless because it actually supports
termination.T
- the type of the stream elementsroot
- the root elementmapping
- a mapping from an element to the next elementpublic static <T> java.util.stream.Stream<T> iterateOptional(java.util.Optional<? extends T> root, java.util.function.Function<? super T,java.util.Optional<? extends T>> mapping)
Stream.iterate(Object, UnaryOperator)
but not
completely and utterly useless because it actually supports
termination.T
- the type of the stream elementsroot
- the root elementmapping
- a mapping from an element to the next elementpublic static <T> java.util.stream.Stream<T> flatMapRecursive(T root, java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends T>> mapping)
T
- the type of the stream elementsroot
- the root elementmapping
- a mapping from an element to a stream of its direct childrenpublic static <T> java.util.stream.Stream<T> flatMapRecursive(java.util.stream.Stream<? extends T> stream, java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends T>> mapping)
T
- the type of the stream elementsstream
- the stream of initial elementsmapping
- a mapping from an element to a stream of its direct childrenpublic static <T> java.util.stream.Stream<T> flatMapRecursiveDistinct(T root, java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends T>> mapping)
T
- the type of the stream elementsroot
- the root elementmapping
- a mapping from an element to a stream of its direct childrenpublic static <T> java.util.stream.Stream<T> flatMapRecursiveDistinct(java.util.stream.Stream<? extends T> stream, java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends T>> mapping)
Repeated elements will be ignored.
T
- the type of the stream elementsstream
- the stream of initial elementsmapping
- a mapping from an element to a stream of its direct childrenprotected static <T> java.util.stream.Stream<T> flatMapRecursiveDistinct(java.util.stream.Stream<? extends T> stream, java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends T>> mapping, java.util.Set<T> visited)