public interface FoldableTraversable<T> extends Traversable<T>, CyclopsCollectable<T>, ExtendedTraversable<T>
| Modifier and Type | Method and Description |
|---|---|
default Fn1<java.lang.Long,T> |
asFunction() |
default <R> Future<R> |
foldFuture(java.util.concurrent.Executor ex,
java.util.function.Function<? super FoldableTraversable<T>,? extends R> fn)
Perform an async fold on the provided executor
|
default <R> Eval<R> |
foldLazy(java.util.function.Function<? super FoldableTraversable<T>,? extends R> fn)
Perform a maybe caching fold (results are memoized)
|
default <R,X extends java.lang.Throwable> |
foldTry(java.util.function.Function<? super FoldableTraversable<T>,? extends R> fn,
java.lang.Class<X>... classes)
Try a fold, capturing any unhandling execution exceptions (that match the provided classes)
|
default <X extends java.lang.Throwable> |
forEach(java.util.function.Consumer<? super T> consumerElement,
java.util.function.Consumer<? super java.lang.Throwable> consumerError)
Perform a forEach operation over the Stream capturing any elements and errors in the supplied consumers,
|
default <X extends java.lang.Throwable> |
forEach(java.util.function.Consumer<? super T> consumerElement,
java.util.function.Consumer<? super java.lang.Throwable> consumerError,
java.lang.Runnable onComplete)
Perform a forEach operation over the Stream capturing any elements and errors in the supplied consumers
when the entire Stream has been processed an onComplete event will be recieved.
|
default <X extends java.lang.Throwable> |
forEach(long numberOfElements,
java.util.function.Consumer<? super T> consumer)
Perform a forEach operation over the Stream, without closing it, consuming only the specified number of elements from
the Stream, at this time.
|
default <X extends java.lang.Throwable> |
forEach(long numberOfElements,
java.util.function.Consumer<? super T> consumer,
java.util.function.Consumer<? super java.lang.Throwable> consumerError)
Perform a forEach operation over the Stream without closing it, capturing any elements and errors in the supplied consumers, but only consuming
the specified number of elements from the Stream, at this time.
|
default <X extends java.lang.Throwable> |
forEach(long numberOfElements,
java.util.function.Consumer<? super T> consumer,
java.util.function.Consumer<? super java.lang.Throwable> consumerError,
java.lang.Runnable onComplete)
Perform a forEach operation over the Stream without closing it, capturing any elements and errors in the supplied consumers, but only consuming
the specified number of elements from the Stream, at this time.
|
default <X extends java.lang.Throwable> |
forEachSubscribe(java.util.function.Consumer<? super T> consumer)
Perform a forEach operation over the Stream, without closing it, consuming only the specified number of elements from
the Stream, at this time.
|
default <X extends java.lang.Throwable> |
forEachSubscribe(java.util.function.Consumer<? super T> consumer,
java.util.function.Consumer<? super java.lang.Throwable> consumerError)
Perform a forEach operation over the Stream without closing it, capturing any elements and errors in the supplied consumers, but only consuming
the specified number of elements from the Stream, at this time.
|
default <X extends java.lang.Throwable> |
forEachSubscribe(java.util.function.Consumer<? super T> consumer,
java.util.function.Consumer<? super java.lang.Throwable> consumerError,
java.lang.Runnable onComplete)
Perform a forEach operation over the Stream without closing it, capturing any elements and errors in the supplied consumers, but only consuming
the specified number of elements from the Stream, at this time.
|
default HeadAndTail<T> |
headAndTail()
extract head and tail together, where head is expected to be present
Example :
|
default Future<java.lang.Void> |
runFuture(java.util.concurrent.Executor ex,
java.util.function.Consumer<? super FoldableTraversable<T>> fn) |
default Eval<java.lang.Void> |
runLazy(java.util.function.Consumer<? super FoldableTraversable<T>> fn) |
default org.jooq.lambda.Seq<T> |
seq() |
ReactiveSeq<T> |
stream() |
default ListX<T> |
toListX() |
default SetX<T> |
toSetX() |
default <R> R |
visit(java.util.function.BiFunction<? super T,? super ReactiveSeq<T>,? extends R> match,
java.util.function.Supplier<? extends R> ifEmpty)
Destructures this Traversable into it's head and tail.
|
allMatch, anyMatch, collect, collectors, commonPrefix, commonSuffix, count, count, countDistinct, countDistinct, countDistinctBy, countDistinctBy, max, maxBy, min, minBy, mode, noneMatch, sum, sumDouble, sumInt, sumLong, to, toList, toMap, toMap, toSet, toString, toStringendsWith, endsWithIterable, findAny, findFirst, firstValue, foldLeft, foldLeft, foldLeft, foldLeft, foldRight, foldRight, foldRight, foldRightMapToType, get, groupBy, join, join, join, mapReduce, mapReduce, print, print, printErr, printOut, reduce, reduce, reduce, reduce, reduce, reduce, reduce, schedule, scheduleFixedDelay, scheduleFixedRate, single, single, singleUnsafe, startsWith, startsWithIterable, takeOne, xMatchcombinations, combinations, permutationsappend, append, combine, combine, cycle, cycle, cycleUntil, cycleWhile, deleteBetween, distinct, drop, dropRight, dropUntil, dropWhile, grouped, grouped, grouped, grouped, groupedStatefullyUntil, groupedUntil, groupedUntil, groupedWhile, groupedWhile, insertAt, insertAtS, intersperse, limit, limitLast, limitUntil, limitWhile, mapToDouble, mapToInt, mapToLong, onEmpty, onEmptyGet, onEmptyThrow, prepend, prepend, prependS, recover, recover, reverse, scanLeft, scanLeft, scanRight, scanRight, shuffle, shuffle, skip, skipLast, skipUntil, skipWhile, slice, sliding, sliding, sorted, sorted, sorted, subscribe, take, takeRight, takeUntil, takeWhile, traversable, unitIterator, zip, zip, zip, zip3, zip3, zip4, zip4, zipP, zipP, zipS, zipS, zipWith, zipWithIndex, zipWithP, zipWithSremoveAll, removeAllI, removeAllS, retainAll, retainAllI, retainAllSfilter, mapcast, peek, retry, retry, trampolinegroupedStatefullyUntilT, groupedT, groupedUntilT, groupedWhileT, slidingT, slidingTfixedDelay, onePer, xPerdefault <R> Future<R> foldFuture(java.util.concurrent.Executor ex, java.util.function.Function<? super FoldableTraversable<T>,? extends R> fn)
Future<Integer> sum = ListX.of(1,2,3)
.map(this::load)
.foldFuture(exec,list->list.reduce(0,(a,b)->a+b))
Similar to @see ReactiveSeq#futureOperations(Executor), but returns Futurefn - Folding functionex - Executor to perform fold ondefault Future<java.lang.Void> runFuture(java.util.concurrent.Executor ex, java.util.function.Consumer<? super FoldableTraversable<T>> fn)
default <R> Eval<R> foldLazy(java.util.function.Function<? super FoldableTraversable<T>,? extends R> fn)
Eval<Integer> sum = ListX.of(1,2,3)
.map(this::load)
.foldLazy(list->list.reduce(0,(a,b)->a+b))
Similar to @see ReactiveSeq#lazyOperations(), but always returns Eval (e.g. with nested Optionals)fn - Folding functiondefault Eval<java.lang.Void> runLazy(java.util.function.Consumer<? super FoldableTraversable<T>> fn)
default <R,X extends java.lang.Throwable> Try<R,X> foldTry(java.util.function.Function<? super FoldableTraversable<T>,? extends R> fn, java.lang.Class<X>... classes)
Try<Integer,Throwable> sum = ListX.of(1,2,3)
.map(this::load)
.foldLazy(list->list.reduce(0,(a,b)->a+b),IOException.class)
fn - Folding functionclasses - Unhandled Exception types to capture in TryReactiveSeq<T> stream()
stream in interface ExtendedTraversable<T>stream in interface Folds<T>stream in interface Sequential<T>stream in interface TransformerTraversable<T>stream in interface Traversable<T>default org.jooq.lambda.Seq<T> seq()
default <R> R visit(java.util.function.BiFunction<? super T,? super ReactiveSeq<T>,? extends R> match, java.util.function.Supplier<? extends R> ifEmpty)
ListX.of(1,2,3,4,5,6,7,8,9)
.dropRight(5)
.plus(10)
.visit((x,xs) ->
xs.join(x.>2?"hello":"world")),()->"NIL"
);
//2world3world4
match - default HeadAndTail<T> headAndTail()
ReactiveSeq<String> helloWorld = ReactiveSeq.Of("hello","world","last");
HeadAndTail<String> headAndTail = helloWorld.headAndTail();
String head = headAndTail.head();
//head == "hello"
ReactiveSeq<String> tail = headAndTail.tail();
//["world","last]
default <X extends java.lang.Throwable> org.reactivestreams.Subscription forEachSubscribe(java.util.function.Consumer<? super T> consumer)
ReactiveStreamsTerminalOperations
Subscription next = Spouts.of(1,2,3,4)
.forEachSubscribe(System.out::println);
next.request(2);
Thread.sleep(500);
System.out.println("First batch processed!");
next.request(2);
System.out.println("Second batch processed!");
//prints
1
2
First batch processed!
3
4
Second batch processed!
forEachSubscribe in interface ReactiveStreamsTerminalOperations<T>consumer - To accept incoming events from the Streamdefault <X extends java.lang.Throwable> org.reactivestreams.Subscription forEachSubscribe(java.util.function.Consumer<? super T> consumer, java.util.function.Consumer<? super java.lang.Throwable> consumerError)
ReactiveStreamsTerminalOperations
Subscription next = ReactiveSeq.of(()->1,()->2,()->throw new RuntimeException(),()->4)
.map(Supplier::get)
.forEachSubscribe(System.out::println, e->e.printStackTrace());
next.request(2);
System.out.println("First batch processed!");
next.request(2);
System.out.println("Second batch processed!");
//prints
1
2
First batch processed!
RuntimeException Stack Trace on System.err
4
Second batch processed!
forEachSubscribe in interface ReactiveStreamsTerminalOperations<T>consumer - To accept incoming elements from the StreamconsumerError - To accept incoming processing errors from the Streamdefault <X extends java.lang.Throwable> org.reactivestreams.Subscription forEachSubscribe(java.util.function.Consumer<? super T> consumer, java.util.function.Consumer<? super java.lang.Throwable> consumerError, java.lang.Runnable onComplete)
ReactiveStreamsTerminalOperations
Subscription next = ReactiveSeq.of(()->1,()->2,()->throw new RuntimeException(),()->4)
.map(Supplier::get)
.forEachSubscribe(System.out::println, e->e.printStackTrace(),()->System.out.println("the take!"));
next.request(2);
System.out.println("First batch processed!");
next.request(2);
System.out.println("Second batch processed!");
//prints
1
2
First batch processed!
RuntimeException Stack Trace on System.err
4
Second batch processed!
The take!
forEachSubscribe in interface ReactiveStreamsTerminalOperations<T>consumer - To accept incoming elements from the StreamconsumerError - To accept incoming processing errors from the StreamonComplete - To run after an onComplete eventdefault <X extends java.lang.Throwable> org.reactivestreams.Subscription forEach(long numberOfElements,
java.util.function.Consumer<? super T> consumer)
ReactiveStreamsTerminalOperations
Subscription next = ReactiveSeq.of(1,2,3,4)
.forEach(2,System.out::println);
System.out.println("First batch processed!");
next.request(2);
System.out.println("Second batch processed!");
//prints
1
2
First batch processed!
3
4
Second batch processed!
forEach in interface ReactiveStreamsTerminalOperations<T>numberOfElements - To consume from the Stream at this timeconsumer - To accept incoming events from the Streamdefault <X extends java.lang.Throwable> org.reactivestreams.Subscription forEach(long numberOfElements,
java.util.function.Consumer<? super T> consumer,
java.util.function.Consumer<? super java.lang.Throwable> consumerError)
ReactiveStreamsTerminalOperations
Subscription next = ReactiveSeq.of(()->1,()->2,()->throw new RuntimeException(),()->4)
.map(Supplier::get)
.forEach(2,System.out::println, e->e.printStackTrace());
System.out.println("First batch processed!");
next.request(2);
System.out.println("Second batch processed!");
//prints
1
2
First batch processed!
RuntimeException Stack Trace on System.err
4
Second batch processed!
forEach in interface ReactiveStreamsTerminalOperations<T>numberOfElements - To consume from the Stream at this timeconsumer - To accept incoming elements from the StreamconsumerError - To accept incoming processing errors from the Streamdefault <X extends java.lang.Throwable> org.reactivestreams.Subscription forEach(long numberOfElements,
java.util.function.Consumer<? super T> consumer,
java.util.function.Consumer<? super java.lang.Throwable> consumerError,
java.lang.Runnable onComplete)
ReactiveStreamsTerminalOperations
Subscription next = ReactiveSeq.of(()->1,()->2,()->throw new RuntimeException(),()->4)
.map(Supplier::get)
.forEach(2,System.out::println, e->e.printStackTrace(),()->System.out.println("the take!"));
System.out.println("First batch processed!");
next.request(2);
System.out.println("Second batch processed!");
//prints
1
2
First batch processed!
RuntimeException Stack Trace on System.err
4
Second batch processed!
The take!
forEach in interface ReactiveStreamsTerminalOperations<T>numberOfElements - To consume from the Stream at this timeconsumer - To accept incoming elements from the StreamconsumerError - To accept incoming processing errors from the StreamonComplete - To run after an onComplete eventdefault <X extends java.lang.Throwable> void forEach(java.util.function.Consumer<? super T> consumerElement, java.util.function.Consumer<? super java.lang.Throwable> consumerError)
ReactiveStreamsTerminalOperations
Subscription next = ReactiveSeq.of(()->1,()->2,()->throw new RuntimeException(),()->4)
.map(Supplier::get)
.forEach(System.out::println, e->e.printStackTrace());
System.out.println("processed!");
//prints
1
2
RuntimeException Stack Trace on System.err
4
processed!
forEach in interface ReactiveStreamsTerminalOperations<T>consumerElement - To accept incoming elements from the StreamconsumerError - To accept incoming processing errors from the Streamdefault <X extends java.lang.Throwable> void forEach(java.util.function.Consumer<? super T> consumerElement, java.util.function.Consumer<? super java.lang.Throwable> consumerError, java.lang.Runnable onComplete)
ReactiveStreamsTerminalOperations
Subscription next = ReactiveSeq.of(()->1,()->2,()->throw new RuntimeException(),()->4)
.map(Supplier::get)
.forEachEvents(System.out::println, e->e.printStackTrace(),()->System.out.println("the take!"));
System.out.println("processed!");
//prints
1
2
RuntimeException Stack Trace on System.err
4
processed!
forEach in interface ReactiveStreamsTerminalOperations<T>consumerElement - To accept incoming elements from the StreamconsumerError - To accept incoming processing errors from the StreamonComplete - To run after an onComplete event