public interface FoldableTraversable<T> extends Fn1<java.lang.Long,T>, Traversable<T>, CyclopsCollectable<T>, ConvertableSequence<T>, ExtendedTraversable<T>
Fn1.µ, Fn1.FunctionalOperations<T1,R>
Modifier and Type | Method and Description |
---|---|
default T |
apply(java.lang.Long index)
Apply this function to the arguments.
|
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 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 <X extends java.lang.Throwable> |
subscribe(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> |
subscribe(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> |
subscribe(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 <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.
|
andThen, andThen, bind, compose, functionOps, lift, lift, liftF, liftOpt, liftTry, memoize, memoize, product, reader, λ, λv
apply, applyPartially, applyPartially, curry, curry, from, toFunction
allMatch, anyMatch, avg, avgDouble, avgInt, avgLong, bitAnd, bitAndInt, bitAndLong, bitOr, bitOrInt, bitOrLong, collect, collectable, commonPrefix, commonSuffix, count, count, countDistinct, countDistinct, countDistinctBy, countDistinctBy, max, max, max, max, maxAll, maxAll, maxAll, maxAll, maxAllBy, maxAllBy, maxBy, maxBy, median, median, medianBy, medianBy, min, min, min, min, minAll, minAll, minAll, minAll, minAllBy, minAllBy, minBy, minBy, mode, modeAll, modeAllBy, modeBy, noneMatch, percentile, percentile, percentileBy, percentileBy, sum, sumDouble, sumInt, sumLong, toCollection, toList, toList, toMap, toMap, toSet, toSet, toString, toString
endsWith, 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, singleOptional, startsWith, startsWithIterable, toConcurrentLazyCollection, toConcurrentLazyStreamable, toLazyCollection, xMatch
toDequeX, toFutureStream, toFutureStream, toListX, toMapX, toOptional, toPBagX, toPMapX, toPOrderedSetX, toPQueueX, toPSetX, toPStackX, toPVectorX, toQueueX, toSetX, toSimpleReact, toSimpleReact, toSortedSetX, toStreamable, toValue
combinations, combinations, permutations
append, append, 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, zip3, zip4, zipS, zipWithIndex
zip, zip, zip3, zip4, zipP, zipP, zipS, zipWith, zipWithP, zipWithS
futureStream, getStreamable, isEmpty, jdkStream, reactiveSeq, reveresedJDKStream, reveresedStream
removeAllS, removeAllS, removeAllS, retainAllS, retainAllS, retainAllS
filter, map
cast, peek, retry, retry, trampoline
groupedStatefullyUntilT, groupedT, groupedUntilT, groupedWhileT, slidingT, slidingT
fixedDelay, onePer, xPer
default <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(list->list.reduce(0,(a,b)->a+b),exec)
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 Trydefault T apply(java.lang.Long index)
org.jooq.lambda.function.Function1
ReactiveSeq<T> stream()
stream
in interface ConvertableSequence<T>
stream
in interface ExtendedTraversable<T>
stream
in interface Sequential<T>
stream
in interface ToStream<T>
stream
in interface TransformerTraversable<T>
stream
in interface Traversable<T>
default org.jooq.lambda.Seq<T> seq()
seq
in interface ConvertableSequence<T>
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 subscribe(java.util.function.Consumer<? super T> consumer)
ReactiveStreamsTerminalOperations
Subscription next = Spouts.of(1,2,3,4)
.subscribe(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!
subscribe
in interface ReactiveStreamsTerminalOperations<T>
consumer
- To accept incoming events from the Streamdefault <X extends java.lang.Throwable> org.reactivestreams.Subscription subscribe(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)
.subscribe(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!
subscribe
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 subscribe(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)
.subscribe(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!
subscribe
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