public abstract class SpliteratorBasedStream<T> extends BaseExtendedStream<T>
ReactiveSeq.Instances| Constructor and Description |
|---|
SpliteratorBasedStream(java.util.Spliterator<T> stream,
java.util.Optional<ReversableSpliterator> rev) |
SpliteratorBasedStream(java.util.stream.Stream<T> stream) |
SpliteratorBasedStream(java.util.stream.Stream<T> stream,
java.util.Optional<ReversableSpliterator> rev) |
| Modifier and Type | Method and Description |
|---|---|
ReactiveSeq<T> |
append(java.lang.Iterable<? extends T> other) |
ReactiveSeq<T> |
append(T... other)
Append values to the take of this ReactiveSeq
|
ReactiveSeq<T> |
append(T other) |
ReactiveSeq<T> |
appendS(java.util.stream.Stream<? extends T> other)
Append Stream to this ReactiveSeq
|
ReactiveSeq<T> |
changes() |
<R> ReactiveSeq<R> |
coflatMap(java.util.function.Function<? super ReactiveSeq<T>,? extends R> fn)
coflatMap pattern, can be used to perform maybe reductions / collections / folds and other terminal operations
|
org.jooq.lambda.Collectable<T> |
collectors()
Narrow this class to a Collectable
|
<A,R> ReactiveSeq<R> |
collectSeq(java.util.stream.Collector<? super T,A,R> c) |
SpliteratorBasedStream<T> |
complete(java.lang.Runnable fn)
Provide a simpler method to handle stream or async operations.
|
long |
count()
Returns the count of elements in this reactiveStream.
|
protected <X> ReactiveSeq<X> |
createSeq(java.util.stream.Stream<X> stream) |
ReactiveSeq<T> |
distinct() |
<U> ReactiveSeq<T> |
distinct(java.util.function.Function<? super T,? extends U> keyExtractor) |
ReactiveSeq<T> |
filter(java.util.function.Predicate<? super T> fn)
Keep only elements for which the supplied predicates hold
e.g.
|
ReactiveSeq<T> |
filterLazyPredicate(java.util.function.Supplier<java.util.function.Predicate<? super T>> fn) |
java.util.Optional<T> |
findFirst() |
Either<java.lang.Throwable,T> |
findFirstOrError()
Lazy / reactiveBuffer look up of first value , capturing the first error, if one occurs.
|
Maybe<T> |
findOne()
Lazy / reactiveBuffer analogue of findFirst / findAny from JDK
For push based reactiveBuffer-streams (created via Spouts.XXX) data will be pushed to the returned Maybe on arrival.
|
<R> ReactiveSeq<R> |
flatMap(java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends R>> fn)
flatMap operation
|
<R> ReactiveSeq<R> |
flatMapAnyM(java.util.function.Function<? super T,AnyM<Witness.stream,? extends R>> fn)
Allows flatMap return type to be any Monad type
|
<R> ReactiveSeq<R> |
flatMapI(java.util.function.Function<? super T,? extends java.lang.Iterable<? extends R>> fn)
FlatMap where the result is a Collection, flattens the resultant
collections into the host ReactiveSeq
|
<R> ReactiveSeq<R> |
flatMapP(java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)
A potentially asynchronous flatMap operation where data from each publisher may arrive out of order (if publishers
are configured to publish asynchronously, users can use the overloaded @see
IterableFunctor#flatMapPublisher(Function, int, QueueFactory)
method to forEachAsync asynchronously also. |
<R> ReactiveSeq<R> |
flatMapP(int maxConcurrency,
java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)
A potentially asynchronous flatMap operation where data from each publisher may arrive out of order (if publishers
are configured to publish asynchronously, users can use the overloaded @see
IterableFunctor#flatMapPublisher(Function, int, QueueFactory)
method to forEachAsync asynchronously also. |
<R> ReactiveSeq<R> |
flatMapP(int maxConcurrency,
QueueFactory<R> factory,
java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)
A potentially asynchronous flatMap operation where data from each publisher may arrive out of order (if publishers
are configured to publish asynchronously.
|
void |
forEach(java.util.function.Consumer<? super T> action)
Performs an action for each element of this Stream.
|
<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,
|
<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.
|
<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.
|
<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.
|
<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.
|
java.lang.String |
format() |
ReactiveSeq<ListX<T>> |
grouped(int groupSize)
Group elements in a Stream
|
<C extends java.util.Collection<? super T>> |
grouped(int size,
java.util.function.Supplier<C> factory)
Batch elements in a Stream by size into a toX created by the
supplied factory
|
ReactiveSeq<ListX<T>> |
groupedBySizeAndTime(int size,
long time,
java.util.concurrent.TimeUnit t)
Batch elements by size into a List
|
<C extends java.util.Collection<? super T>> |
groupedBySizeAndTime(int size,
long time,
java.util.concurrent.TimeUnit unit,
java.util.function.Supplier<C> factory)
Batch elements by size into a toX created by the supplied factory
|
<C extends java.util.Collection<? super T>,R> |
groupedBySizeAndTime(int size,
long time,
java.util.concurrent.TimeUnit unit,
java.util.function.Supplier<C> factory,
java.util.function.Function<? super C,? extends R> finalizer) |
ReactiveSeq<ListX<T>> |
groupedByTime(long time,
java.util.concurrent.TimeUnit t)
Batch elements in a Stream by time period
|
<C extends java.util.Collection<? super T>> |
groupedByTime(long time,
java.util.concurrent.TimeUnit unit,
java.util.function.Supplier<C> factory)
Batch elements by time into a toX created by the supplied factory
|
<C extends java.util.Collection<? super T>,R> |
groupedByTime(long time,
java.util.concurrent.TimeUnit unit,
java.util.function.Supplier<C> factory,
java.util.function.Function<? super C,? extends R> finalizer) |
<C extends java.util.Collection<T>,R> |
groupedStatefullyUntil(java.util.function.BiPredicate<C,? super T> predicate,
java.util.function.Supplier<C> factory,
java.util.function.Function<? super C,? extends R> finalizer) |
ReactiveSeq<ListX<T>> |
groupedStatefullyUntil(java.util.function.BiPredicate<ListX<? super T>,? super T> predicate)
Create ReactiveSeq of ListX where
each ListX is populated while the supplied bipredicate holds.
|
<C extends java.util.Collection<T>,R> |
groupedStatefullyWhile(java.util.function.BiPredicate<C,? super T> predicate,
java.util.function.Supplier<C> factory,
java.util.function.Function<? super C,? extends R> finalizer) |
ReactiveSeq<ListX<T>> |
groupedStatefullyWhile(java.util.function.BiPredicate<ListX<? super T>,? super T> predicate) |
ReactiveSeq<ListX<T>> |
groupedUntil(java.util.function.Predicate<? super T> predicate)
Create a ReactiveSeq batched by List, where each batch is populated until
the predicate holds
|
<C extends java.util.Collection<? super T>> |
groupedUntil(java.util.function.Predicate<? super T> predicate,
java.util.function.Supplier<C> factory)
Create a ReactiveSeq batched by a Collection, where each batch is populated
until the predicate holds
|
ReactiveSeq<ListX<T>> |
groupedWhile(java.util.function.Predicate<? super T> predicate)
Create a ReactiveSeq batched by List, where each batch is populated while
the predicate holds
|
<C extends java.util.Collection<? super T>> |
groupedWhile(java.util.function.Predicate<? super T> predicate,
java.util.function.Supplier<C> factory)
Create a ReactiveSeq batched by a Collection, where each batch is populated
while the predicate holds
|
java.util.Iterator<T> |
iterator() |
ReactiveSeq<T> |
limit(long num)
assertThat(ReactiveSeq.of(4,3,6,7).limit(2).toList(),equalTo(Arrays.asList(4,3)); |
ReactiveSeq<T> |
limit(long time,
java.util.concurrent.TimeUnit unit)
Return all elements until specified time period has elapsed
|
ReactiveSeq<T> |
limitLast(int num)
Limit results to the last x elements in a ReactiveSeq
|
ReactiveSeq<T> |
limitUntil(java.util.function.Predicate<? super T> p)
Take elements from the Stream until the predicate returns true, after
which all elements are excluded.
|
ReactiveSeq<T> |
limitWhile(java.util.function.Predicate<? super T> p)
Take elements from the Stream while the predicate holds, once the
predicate returns false all subsequent elements are excluded
|
ReactiveSeq<T> |
limitWhileClosed(java.util.function.Predicate<? super T> predicate) |
<R> ReactiveSeq<R> |
map(java.util.function.Function<? super T,? extends R> fn)
Transform this functor using the supplied transformation function
|
<R> ReactiveSeq<R> |
mapLazyFn(java.util.function.Supplier<java.util.function.Function<? super T,? extends R>> fn) |
ReactiveSeq<T> |
onEmpty(T value)
If this Container instance is zero, create a new instance containing the provided value
|
ReactiveSeq<T> |
onEmptyGet(java.util.function.Supplier<? extends T> supplier)
If this Container instance is zero, create a new instance containing the value returned from the provided Supplier
|
ReactiveSeq<T> |
onEmptySwitch(java.util.function.Supplier<? extends java.util.stream.Stream<T>> switchTo)
If this ReactiveSeq is empty one it with a another Stream
|
<X extends java.lang.Throwable> |
onEmptyThrow(java.util.function.Supplier<? extends X> supplier)
If this container instance is zero, throw the exception returned by the provided Supplier
|
ReactiveSeq<T> |
peek(java.util.function.Consumer<? super T> c)
Peek at the current value of this Transformable, without transforming it
|
ReactiveSeq<T> |
prepend(java.lang.Iterable<? extends T> other) |
ReactiveSeq<T> |
prepend(T... other)
Prepend given values to the skip of the Stream
|
ReactiveSeq<T> |
prepend(T other) |
ReactiveSeq<T> |
prependS(java.util.stream.Stream<? extends T> other)
Prepend Stream to this ReactiveSeq
|
<EX extends java.lang.Throwable> |
recover(java.lang.Class<EX> exceptionClass,
java.util.function.Function<? super EX,? extends T> fn)
Recover from a particular exception type
|
ReactiveSeq<T> |
recover(java.util.function.Function<? super java.lang.Throwable,? extends T> fn)
Recover from an exception with an alternative value
|
java.util.Optional<T> |
reduce(java.util.function.BinaryOperator<T> accumulator)
An equivalent function to
Stream.reduce(BinaryOperator) |
T |
reduce(T identity,
java.util.function.BinaryOperator<T> accumulator)
An equivalent function to
Stream.reduce(Object, BinaryOperator) |
<U> ReactiveSeq<U> |
scanLeft(U seed,
java.util.function.BiFunction<? super U,? super T,? extends U> function)
Scan left
|
ReactiveSeq<T> |
skip(long num)
assertThat(ReactiveSeq.of(4,3,6,7).skip(2).toList(),equalTo(Arrays.asList(6,7))); |
ReactiveSeq<T> |
skip(long time,
java.util.concurrent.TimeUnit unit)
Skip all elements until specified time period has passed
|
ReactiveSeq<T> |
skipLast(int num)
assertThat(ReactiveSeq.of(1,2,3,4,5) .skipLast(2)
.collect(CyclopsCollectors.toList()),equalTo(Arrays.asList(1,2,3)));
|
ReactiveSeq<T> |
skipUntil(java.util.function.Predicate<? super T> p)
Drop elements from the Stream until the predicate returns true, after
which all elements are included
|
ReactiveSeq<T> |
skipWhile(java.util.function.Predicate<? super T> p)
SkipWhile drops elements from the Stream while the predicate holds, once
the predicte returns true all subsequent elements are included *
|
ReactiveSeq<T> |
skipWhileClosed(java.util.function.Predicate<? super T> predicate) |
ReactiveSeq<VectorX<T>> |
sliding(int windowSize,
int increment)
Create a sliding view over this Sequence
|
java.util.Spliterator<T> |
spliterator()
Returns a spliterator for the elements of this reactiveStream.
|
void |
subscribe(org.reactivestreams.Subscriber<? super T> sub) |
<T> ReactiveSeq<T> |
unit(T unit) |
<T> ReactiveSeq<T> |
unitIterator(java.util.Iterator<T> it)
Create an IterableFunctor instance of the same type from an Iterator
|
java.util.stream.Stream<T> |
unwrapStream() |
<S,U> ReactiveSeq<org.jooq.lambda.tuple.Tuple3<T,S,U>> |
zip3(java.lang.Iterable<? extends S> second,
java.lang.Iterable<? extends U> third)
zip 3 Streams into one
|
<S,U,R> ReactiveSeq<R> |
zip3(java.lang.Iterable<? extends S> second,
java.lang.Iterable<? extends U> third,
Fn3<? super T,? super S,? super U,? extends R> fn3) |
<T2,T3,T4> ReactiveSeq<org.jooq.lambda.tuple.Tuple4<T,T2,T3,T4>> |
zip4(java.lang.Iterable<? extends T2> second,
java.lang.Iterable<? extends T3> third,
java.lang.Iterable<? extends T4> fourth)
zip 4 Streams into 1
|
<T2,T3,T4,R> |
zip4(java.lang.Iterable<? extends T2> second,
java.lang.Iterable<? extends T3> third,
java.lang.Iterable<? extends T4> fourth,
Fn4<? super T,? super T2,? super T3,? super T4,? extends R> fn) |
<S> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,S>> |
zipS(java.util.stream.Stream<? extends S> second)
Zip 2 streams into one
|
<U,R> ReactiveSeq<R> |
zipS(java.util.stream.Stream<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
Zip (combine) this Zippable with the supplied Stream, using the supplied combining function
|
allMatch, anyM, anyMatch, close, collect, collect, debounce, endsWith, endsWithIterable, findAny, firstValue, fixedDelay, flatMapBufferedReader, flatMapCharSequence, flatMapCompletableFuture, flatMapFile, flatMapOptional, flatMapStream, flatMapToDouble, flatMapToInt, flatMapToLong, flatMapURL, foldLeft, foldLeft, foldLeftMapToType, foldRight, foldRight, foldRight, foldRightMapToType, forEachOrdered, headAndTail, isParallel, jitter, join, join, join, mapReduce, mapReduce, mapToDouble, mapToInt, mapToLong, max, maxBy, min, minBy, noneMatch, onClose, onePer, parallel, reduce, reduce, reduce, reduce, sequential, sorted, startsWith, startsWithIterable, stream, toArray, toArray, toList, toSet, unordered, xMatch, xPerclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitunwrap, unwrapIfInstance, unwrapNestedallTypeclasses, allTypeclasses, ambWith, ambWith, backpressureAware, broadcast, cast, collectAll, collectStream, combinations, combinations, combinationsT, combinationsT, combine, combine, concat, concat, concat, concat, concatDoubles, concatInts, concatLongs, coproduct, crossJoin, cycle, cycle, cycle, cycleUntil, cycleWhile, deferred, deferredI, deferredP, deleteBetween, doubles, drop, dropRight, dropUntil, dropWhile, duplicate, duplicate, elapsed, elementAt, empty, enqueued, enqueued, enqueued, enqueuedAll, enums, enums, enums, enumsFromTo, fanOut, fanOut, fanOut, fanOutZipIn, fanOutZipIn, fanOutZipIn, fill, filterInts, filterLongs, filterLongs, filterNot, flatMapDoubles, flatMapInts, flatMapLongs, flatten, flattenI, flattenO, foldJool, foldParallel, foldParallel, forEach2, forEach2, forEach3, forEach3, forEach4, forEach4, forEachAsync, fromCharSequence, fromDoubleStream, fromIntStream, fromIterable, fromIterator, fromList, fromLongStream, fromPublisher, fromSpliterator, fromStream, generate, generate, get, groupBy, grouped, grouped, hotStream, insertAt, insertAtS, intersperse, ints, isEmpty, isReplayable, iterate, iterate, jool, kindCokleisli, kindKleisli, liftM, limitDouble, limitInts, limitLongs, limitUntilClosed, longs, mapDoubles, mapInts, mapLongs, mapM, merge, mergeP, mergeP, multicast, narrowK, nested, notNull, of, of, ofDoubles, ofInts, ofLongs, ofNullable, ofType, oneShotList, oneShotStream, parallel, parallel, parallelFanOut, parallelFanOut, parallelFanOut, parallelFanOutZipIn, parallelFanOutZipIn, parallelFanOutZipIn, partition, pausableHotStream, permutations, permutationsT, primedHotStream, primedPausableHotStream, print, print, printErr, printOut, product, product, publishTo, publishTo, quadruplicate, quadruplicate, range, range, rangeLong, rangeLong, reactiveSeq, reduce, reduceAll, remove, removeAll, removeAllI, removeAllS, retainAll, retainAllI, retainAllS, retry, retry, reverse, reversedListOf, reversedOf, scanLeft, scanRight, scanRight, schedule, scheduleFixedDelay, scheduleFixedRate, seq, shuffle, shuffle, single, single, singleUnsafe, size, skipDoubles, skipInts, skipLongs, skipUntilClosed, slice, sliding, sorted, sorted, sorted, splitAt, splitAtHead, splitBy, subStream, tailRec, take, takeOne, takeRight, takeUntil, takeWhile, timestamp, trampoline, triplicate, triplicate, unfold, unzip, unzip3, unzip4, visit, widen, zip, zip, zip, zipLatest, zipP, zipP, zipWith, zipWithIndex, zipWithP, zipWithSasFunction, foldFuture, foldLazy, foldTry, forEachSubscribe, forEachSubscribe, forEachSubscribe, runFuture, runLazy, toListX, toSetX, visitcommonPrefix, commonSuffix, count, countDistinct, countDistinct, countDistinctBy, countDistinctBy, mode, sum, sumDouble, sumInt, sumLong, to, toMap, toMap, toString, toStringtraversablegroupedStatefullyUntilT, groupedT, groupedUntilT, groupedWhileT, slidingT, slidingTpublic SpliteratorBasedStream(java.util.stream.Stream<T> stream)
public SpliteratorBasedStream(java.util.Spliterator<T> stream, java.util.Optional<ReversableSpliterator> rev)
public SpliteratorBasedStream(java.util.stream.Stream<T> stream, java.util.Optional<ReversableSpliterator> rev)
public SpliteratorBasedStream<T> complete(java.lang.Runnable fn)
ReactiveSeqfn - Function that accepts and returns completed valuepublic java.util.Iterator<T> iterator()
public <R> ReactiveSeq<R> coflatMap(java.util.function.Function<? super ReactiveSeq<T>,? extends R> fn)
ReactiveSeq
ReactiveSeq.of(1,2,3)
.map(i->i*2)
.coflatMap(s -> s.reduce(0,(a,b)->a+b))
//ReactiveSeq[12]
public Either<java.lang.Throwable,T> findFirstOrError()
ReactiveSeqpublic Maybe<T> findOne()
ReactiveSeqpublic <A,R> ReactiveSeq<R> collectSeq(java.util.stream.Collector<? super T,A,R> c)
public <T> ReactiveSeq<T> unit(T unit)
public java.util.stream.Stream<T> unwrapStream()
unwrapStream in class BaseExtendedStream<T>public final <S> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,S>> zipS(java.util.stream.Stream<? extends S> second)
ReactiveSeq
List<Tuple2<Integer, String>> list = of(1, 2).zip(of("a", "b", "c", "d")).toList();
// [[1,"a"],[2,"b"]]
second - Stream to combine withpublic final <U,R> ReactiveSeq<R> zipS(java.util.stream.Stream<? extends U> other, java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
Zippableother - Stream to combine withzipper - Zip / combining functionpublic final <S,U,R> ReactiveSeq<R> zip3(java.lang.Iterable<? extends S> second, java.lang.Iterable<? extends U> third, Fn3<? super T,? super S,? super U,? extends R> fn3)
public <S,U> ReactiveSeq<org.jooq.lambda.tuple.Tuple3<T,S,U>> zip3(java.lang.Iterable<? extends S> second, java.lang.Iterable<? extends U> third)
ReactiveSeq
List<Tuple3<Integer, Integer, Character>> list = of(1, 2, 3, 4, 5, 6).zip3(of(100, 200, 300, 400), of('a', 'b', 'c')).collect(CyclopsCollectors.toList());
// [[1,100,'a'],[2,200,'b'],[3,300,'c']]
public <T2,T3,T4,R> ReactiveSeq<R> zip4(java.lang.Iterable<? extends T2> second, java.lang.Iterable<? extends T3> third, java.lang.Iterable<? extends T4> fourth, Fn4<? super T,? super T2,? super T3,? super T4,? extends R> fn)
public final <T2,T3,T4> ReactiveSeq<org.jooq.lambda.tuple.Tuple4<T,T2,T3,T4>> zip4(java.lang.Iterable<? extends T2> second, java.lang.Iterable<? extends T3> third, java.lang.Iterable<? extends T4> fourth)
ReactiveSeq
List<Tuple4<Integer, Integer, Character, String>> list = of(1, 2, 3, 4, 5, 6).zip4(of(100, 200, 300, 400), of('a', 'b', 'c'), of("hello", "world"))
.collect(CyclopsCollectors.toList());
// [[1,100,'a',"hello"],[2,200,'b',"world"]]
public final ReactiveSeq<VectorX<T>> sliding(int windowSize, int increment)
ReactiveSeq
List<List<Integer>> list = ReactiveSeq.of(1, 2, 3, 4, 5, 6).sliding(3, 2).collect(CyclopsCollectors.toList());
assertThat(list.get(0), hasItems(1, 2, 3));
assertThat(list.get(1), hasItems(3, 4, 5));
windowSize - number of elements in each batchincrement - for each windowpublic ReactiveSeq<ListX<T>> grouped(int groupSize)
ReactiveSeq
List<List<Integer>> list = ReactiveSeq.of(1, 2, 3, 4, 5, 6).grouped(3).collect(CyclopsCollectors.toList());
assertThat(list.get(0), hasItems(1, 2, 3));
assertThat(list.get(1), hasItems(4, 5, 6));
groupSize - Size of each Grouppublic ReactiveSeq<ListX<T>> groupedStatefullyWhile(java.util.function.BiPredicate<ListX<? super T>,? super T> predicate)
public <C extends java.util.Collection<T>,R> ReactiveSeq<R> groupedStatefullyWhile(java.util.function.BiPredicate<C,? super T> predicate, java.util.function.Supplier<C> factory, java.util.function.Function<? super C,? extends R> finalizer)
public ReactiveSeq<ListX<T>> groupedStatefullyUntil(java.util.function.BiPredicate<ListX<? super T>,? super T> predicate)
ReactiveSeq
ReactiveSeq.of(1,2,3,4,5,6)
.groupedStatefullyUntil((s,i)-> s.contains(4) ? true : false)
.toList()
.size()
//5
predicate - Window while truepublic <C extends java.util.Collection<T>,R> ReactiveSeq<R> groupedStatefullyUntil(java.util.function.BiPredicate<C,? super T> predicate, java.util.function.Supplier<C> factory, java.util.function.Function<? super C,? extends R> finalizer)
public final ReactiveSeq<T> distinct()
public final <U> ReactiveSeq<U> scanLeft(U seed, java.util.function.BiFunction<? super U,? super T,? extends U> function)
ReactiveSeq
assertThat(of("a", "b", "c").scanLeft("", String::concat).toList().size(),
is(4));
public ReactiveSeq<T> skip(long num)
ReactiveSeq
assertThat(ReactiveSeq.of(4,3,6,7).skip(2).toList(),equalTo(Arrays.asList(6,7)));
num - Number of elemenets to skippublic final ReactiveSeq<T> skipWhile(java.util.function.Predicate<? super T> p)
ReactiveSeq
assertThat(ReactiveSeq.of(4,3,6,7).sorted().skipWhile(i->i<6).toList(),equalTo(Arrays.asList(6,7)));
p - Predicate to skip while truepublic final ReactiveSeq<T> skipUntil(java.util.function.Predicate<? super T> p)
ReactiveSeq
assertThat(ReactiveSeq.of(4,3,6,7).skipUntil(i->i==6).toList(),equalTo(Arrays.asList(6,7)));
p - Predicate to skip until truepublic ReactiveSeq<T> limit(long num)
ReactiveSeq
assertThat(ReactiveSeq.of(4,3,6,7).limit(2).toList(),equalTo(Arrays.asList(4,3));
num - Limit element size to numpublic final ReactiveSeq<T> limitWhile(java.util.function.Predicate<? super T> p)
ReactiveSeq
assertThat(ReactiveSeq.of(4,3,6,7).sorted().limitWhile(i->i<6).toList(),equalTo(Arrays.asList(3,4)));
p - Limit while predicate is truepublic final ReactiveSeq<T> limitUntil(java.util.function.Predicate<? super T> p)
ReactiveSeq
assertThat(ReactiveSeq.of(4,3,6,7).limitUntil(i->i==6).toList(),equalTo(Arrays.asList(4,3)));
p - Limit until predicate is truepublic ReactiveSeq<T> skipWhileClosed(java.util.function.Predicate<? super T> predicate)
public ReactiveSeq<T> limitWhileClosed(java.util.function.Predicate<? super T> predicate)
public final java.util.Optional<T> findFirst()
ReactiveSeq.of(1,2,3,4,5).filter(it -> it <3).findFirst().get();
//3
(deterministic)public final java.util.Optional<T> reduce(java.util.function.BinaryOperator<T> accumulator)
FoldsStream.reduce(BinaryOperator)
ReactiveSeq.of(1,2,3,4,5).map(it -> it*100).reduce(
(acc,next) -> acc+next)
//Optional[1500]
reduce in interface Folds<T>reduce in interface ReactiveSeq<T>reduce in interface java.util.stream.Stream<T>reduce in class BaseExtendedStream<T>accumulator - Combiner functionpublic final T reduce(T identity, java.util.function.BinaryOperator<T> accumulator)
FoldsStream.reduce(Object, BinaryOperator)reduce in interface Folds<T>reduce in interface ReactiveSeq<T>reduce in interface java.util.stream.Stream<T>reduce in class BaseExtendedStream<T>accumulator - Combiner functionpublic final <R> ReactiveSeq<R> map(java.util.function.Function<? super T,? extends R> fn)
Transformable
of(1,2,3).map(i->i*2)
//[2,4,6]
fn - Transformation functionpublic final ReactiveSeq<T> peek(java.util.function.Consumer<? super T> c)
Transformable
of(1,2,3).map(System.out::println)
1
2
3
c - Consumer that recieves each element from this Transformablepublic final <R> ReactiveSeq<R> flatMap(java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends R>> fn)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2)
.flatMap(i -> asList(i, -i).reactiveStream())
.toList(),equalTo(asList(1, -1, 2, -2)));
fn - to be appliedpublic final <R> ReactiveSeq<R> flatMapAnyM(java.util.function.Function<? super T,AnyM<Witness.stream,? extends R>> fn)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3)).flatMapAnyM(i-> fromEither5(CompletableFuture.completedFuture(i+2))).toList(),equalTo(Arrays.asList(3,4,5)));
fn - to be appliedpublic final <R> ReactiveSeq<R> flatMapI(java.util.function.Function<? super T,? extends java.lang.Iterable<? extends R>> fn)
ReactiveSeq
ReactiveSeq.of(1,2)
.flatMap(i -> asList(i, -i))
.toList();
//1,-1,2,-2
public <R> ReactiveSeq<R> flatMapP(java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)
IterableFunctor#flatMapPublisher(Function, int, QueueFactory)
method to forEachAsync asynchronously also. A default limit of 10k active publishers is enforced, along with a default limit of 5k queued values before
backpressure is applied.mapper - public <R> ReactiveSeq<R> flatMapP(int maxConcurrency, java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)
IterableFunctor#flatMapPublisher(Function, int, QueueFactory)
method to forEachAsync asynchronously also. Active publishers are limited by the maxConcurrency parameter, along with a default limit of 5k queued values before
backpressure is applied.mapper - public <R> ReactiveSeq<R> flatMapP(int maxConcurrency, QueueFactory<R> factory, java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)
QueueFactoriesprotected <X> ReactiveSeq<X> createSeq(java.util.stream.Stream<X> stream)
createSeq in class BaseExtendedStream<T>public final ReactiveSeq<T> filter(java.util.function.Predicate<? super T> fn)
Filters
of(1,2,3).filter(i->i>2);
//[3]
fn - to filter elements by, retaining matchespublic final ReactiveSeq<T> filterLazyPredicate(java.util.function.Supplier<java.util.function.Predicate<? super T>> fn)
filterLazyPredicate in class BaseExtendedStream<T>public void forEach(java.util.function.Consumer<? super T> action)
ReactiveSeqReactiveSeq.forEachAsync(Consumer) and forEach overloads
such as FoldableTraversable.forEach(Consumer, Consumer) and FoldableTraversable.forEach(Consumer, Consumer,Runnable)
This method overrides the JDK Stream.forEach(Consumer) and maintains it's blocking
semantics. Other forEach overloads in ReactiveSeq are non-blocking for asynchronously executing Streams.
This is a terminal operation.
The behavior of this operation is explicitly nondeterministic. For parallel reactiveStream pipelines, this operation does not guarantee to respect the encounter order of the reactiveStream, as doing so would sacrifice the benefit of parallelism. For any given element, the action may be performed at whatever time and in whatever thread the library chooses. If the action accesses shared state, it is responsible for providing the required synchronization.
action - a
non-interfering action to perform on the elementspublic java.util.Spliterator<T> spliterator()
ReactiveSeq
This is a terminal operation.
public long count()
ReactiveSeq
return mapToLong(e -> 1L).sum();
This is a terminal operation.
public ReactiveSeq<T> changes()
public void subscribe(org.reactivestreams.Subscriber<? super T> sub)
public ReactiveSeq<T> onEmpty(T value)
OnEmptypublic ReactiveSeq<T> onEmptySwitch(java.util.function.Supplier<? extends java.util.stream.Stream<T>> switchTo)
ReactiveSeq
assertThat(ReactiveSeq.of(4,5,6)
.onEmptySwitch(()->ReactiveSeq.of(1,2,3))
.toList(),
equalTo(Arrays.asList(4,5,6)));
switchTo - Supplier that will generate the alternative Streampublic ReactiveSeq<T> onEmptyGet(java.util.function.Supplier<? extends T> supplier)
OnEmptysupplier - to determine new value for containerpublic <X extends java.lang.Throwable> ReactiveSeq<T> onEmptyThrow(java.util.function.Supplier<? extends X> supplier)
OnEmptysupplier - to create exception frompublic ReactiveSeq<T> appendS(java.util.stream.Stream<? extends T> other)
ReactiveSeq
List<String> result = ReactiveSeq.of(1, 2, 3).appendStream(ReactiveSeq.of(100, 200, 300)).map(it -> it + "!!").collect(CyclopsCollectors.toList());
assertThat(result, equalTo(Arrays.asList("1!!", "2!!", "3!!", "100!!", "200!!", "300!!"))); *
public ReactiveSeq<T> append(java.lang.Iterable<? extends T> other)
public ReactiveSeq<T> append(T other)
public ReactiveSeq<T> append(T... other)
ReactiveSeq
List<String> result = ReactiveSeq.of(1, 2, 3).append(100, 200, 300).map(it -> it + "!!").collect(CyclopsCollectors.toList());
assertThat(result, equalTo(Arrays.asList("1!!", "2!!", "3!!", "100!!", "200!!", "300!!"))); *
other - to appendpublic ReactiveSeq<T> prependS(java.util.stream.Stream<? extends T> other)
ReactiveSeq
List<String> result = ReactiveSeq.of(1, 2, 3)
.prependS(of(100, 200, 300))
.map(it -> it + "!!")
.collect(CyclopsCollectors.toList());
assertThat(result, equalTo(Arrays.asList("100!!", "200!!", "300!!", "1!!", "2!!", "3!!")));
other - to Prependpublic ReactiveSeq<T> prepend(java.lang.Iterable<? extends T> other)
public ReactiveSeq<T> prepend(T other)
public ReactiveSeq<T> prepend(T... other)
ReactiveSeq
List<String> result = ReactiveSeq.of(1,2,3)
.prepend(100,200,300)
.map(it ->it+"!!")
.collect(CyclopsCollectors.toList());
assertThat(result,equalTo(Arrays.asList("100!!","200!!","300!!","1!!","2!!","3!!")));
other - to prependpublic <U> ReactiveSeq<T> distinct(java.util.function.Function<? super T,? extends U> keyExtractor)
public ReactiveSeq<ListX<T>> groupedBySizeAndTime(int size, long time, java.util.concurrent.TimeUnit t)
ReactiveSeq
ReactiveSeq.of(1,2,3,4,5,6)
.groupedBySizeAndTime(3,10,TimeUnit.SECONDS)
.toList();
//[[1,2,3],[4,5,6]]
size - Max size of a batchtime - (Max) time period to build a singleUnsafe batch int - time unit for batchpublic <R> ReactiveSeq<R> mapLazyFn(java.util.function.Supplier<java.util.function.Function<? super T,? extends R>> fn)
mapLazyFn in class BaseExtendedStream<T>public ReactiveSeq<ListX<T>> groupedByTime(long time, java.util.concurrent.TimeUnit t)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3,4,5,6).batchByTime(1,TimeUnit.SECONDS).collect(CyclopsCollectors.toList()).size(),is(1));
assertThat(ReactiveSeq.of(1,2,3,4,5,6).batchByTime(1,TimeUnit.NANOSECONDS).collect(CyclopsCollectors.toList()).size(),greaterThan(5));
time - - time period to build a singleUnsafe batch int - time unit for batchpublic ReactiveSeq<T> skip(long time, java.util.concurrent.TimeUnit unit)
ReactiveSeq
List<Integer> result = ReactiveSeq.of(1, 2, 3, 4, 5, 6).peek(i -> sleep(i * 100)).skip(1000, TimeUnit.MILLISECONDS).toList();
// [4,5,6]
time - Length of timeunit - Time unitpublic ReactiveSeq<T> limit(long time, java.util.concurrent.TimeUnit unit)
ReactiveSeq
List<Integer> result = ReactiveSeq.of(1, 2, 3, 4, 5, 6).peek(i -> sleep(i * 100)).limit(1000, TimeUnit.MILLISECONDS).toList();
// [1,2,3,4]
time - Length of timeunit - Time unitpublic ReactiveSeq<ListX<T>> groupedUntil(java.util.function.Predicate<? super T> predicate)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3,4,5,6)
.batchUntil(i->i%3==0)
.toList()
.size(),equalTo(2));
predicate - Batch until predicate holds, applyHKT open next batchpublic ReactiveSeq<ListX<T>> groupedWhile(java.util.function.Predicate<? super T> predicate)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3,4,5,6)
.batchWhile(i->i%3!=0)
.toList().size(),equalTo(2));
predicate - Batch while predicate holds, applyHKT open next batchpublic <C extends java.util.Collection<? super T>> ReactiveSeq<C> groupedWhile(java.util.function.Predicate<? super T> predicate, java.util.function.Supplier<C> factory)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3,4,5,6)
.batchWhile(i->i%3!=0)
.toList()
.size(),equalTo(2));
predicate - Batch while predicate holds, applyHKT open next batchfactory - Collection factorypublic <C extends java.util.Collection<? super T>> ReactiveSeq<C> groupedUntil(java.util.function.Predicate<? super T> predicate, java.util.function.Supplier<C> factory)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3,4,5,6)
.batchUntil(i->i%3!=0)
.toList()
.size(),equalTo(2));
predicate - Batch until predicate holds, applyHKT open next batchfactory - Collection factorypublic <C extends java.util.Collection<? super T>> ReactiveSeq<C> groupedBySizeAndTime(int size, long time, java.util.concurrent.TimeUnit unit, java.util.function.Supplier<C> factory)
ReactiveSeq
ReactiveSeq.of(1,2,3,4,5,6)
.groupedBySizeAndTime(3,10,TimeUnit.SECONDS,()->SetX.empty())
.toList();
//[[1,2,3],[4,5,6]]
size - Max size of a batchtime - (Max) time period to build a singleUnsafe batch inunit - time unit for batchfactory - Collection factorypublic <C extends java.util.Collection<? super T>,R> ReactiveSeq<R> groupedBySizeAndTime(int size, long time, java.util.concurrent.TimeUnit unit, java.util.function.Supplier<C> factory, java.util.function.Function<? super C,? extends R> finalizer)
public <C extends java.util.Collection<? super T>,R> ReactiveSeq<R> groupedByTime(long time, java.util.concurrent.TimeUnit unit, java.util.function.Supplier<C> factory, java.util.function.Function<? super C,? extends R> finalizer)
public <C extends java.util.Collection<? super T>> ReactiveSeq<C> groupedByTime(long time, java.util.concurrent.TimeUnit unit, java.util.function.Supplier<C> factory)
ReactiveSeq
assertThat(ReactiveSeq.of(1,1,1,1,1,1)
.batchByTime(1500,TimeUnit.MICROSECONDS,()-> new TreeSet<>())
.toList()
.get(0)
.size(),is(1));
time - - time period to build a singleUnsafe batch inunit - time unit for batchfactory - Collection factorypublic <C extends java.util.Collection<? super T>> ReactiveSeq<C> grouped(int size, java.util.function.Supplier<C> factory)
ReactiveSeq
assertThat(ReactiveSeq.of(1,1,1,1,1,1)
.batchBySize(3,()->new TreeSet<>())
.toList()
.get(0)
.size(),is(1));
size - batch sizefactory - Collection factorypublic ReactiveSeq<T> skipLast(int num)
ReactiveSeqpublic ReactiveSeq<T> limitLast(int num)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3,4,5)
.limitLast(2)
.collect(CyclopsCollectors.toList()),equalTo(Arrays.asList(4,5)));
num - of elements to return (last elements)public ReactiveSeq<T> recover(java.util.function.Function<? super java.lang.Throwable,? extends T> fn)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3,4)
.map(i->i+2)
.map(u->{throw new RuntimeException();})
.recover(e->"hello")
.firstValue(),equalTo("hello"));
fn - Function that accepts a Throwable and returns an alternative
valuepublic <EX extends java.lang.Throwable> ReactiveSeq<T> recover(java.lang.Class<EX> exceptionClass, java.util.function.Function<? super EX,? extends T> fn)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3,4)
.map(i->i+2)
.map(u->{ExceptionSoftener.throwSoftenedException( new IOException()); return null;})
.recover(IOException.class,e->"hello")
.firstValue(),equalTo("hello"));
exceptionClass - Type to recover fromfn - That accepts an error and returns an alternative valuepublic <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!
numberOfElements - To consume from the Stream at this timeconsumer - To accept incoming events from the Streampublic <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!
numberOfElements - To consume from the Stream at this timeconsumer - To accept incoming elements from the StreamconsumerError - To accept incoming processing errors from the Streampublic <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!
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 eventpublic <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!
consumerElement - To accept incoming elements from the StreamconsumerError - To accept incoming processing errors from the Streampublic <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!
consumerElement - To accept incoming elements from the StreamconsumerError - To accept incoming processing errors from the StreamonComplete - To run after an onComplete eventpublic java.lang.String format()
public org.jooq.lambda.Collectable<T> collectors()
CyclopsCollectablepublic <T> ReactiveSeq<T> unitIterator(java.util.Iterator<T> it)
Traversable
ReactiveSeq<Integer> newSeq = seq.unitIterable(myIterator);
it - Iterator to create new IterableFunctor from