public class ReactiveStreamX<T> extends BaseExtendedStream<T>
| Modifier and Type | Class and Description |
|---|---|
static class |
ReactiveStreamX.Type |
ReactiveSeq.Instances| Constructor and Description |
|---|
ReactiveStreamX(Operator<T> source) |
ReactiveStreamX(Operator<T> source,
ReactiveStreamX.Type async) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
allMatch(java.util.function.Predicate<? super T> c)
True if predicate matches all elements when Monad converted to a Stream
|
boolean |
anyMatch(java.util.function.Predicate<? super T> c)
True if a singleUnsafe element matches when Monad converted to a Stream
|
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> |
backpressureAware() |
Topic<T> |
broadcast() |
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
|
<R,A> R |
collect(java.util.stream.Collector<? super T,A,R> collector)
Performs a mutable
reduction operation on the elements of this reactiveStream using a
Collector. |
<R> R |
collect(java.util.function.Supplier<R> supplier,
java.util.function.BiConsumer<R,? super T> accumulator,
java.util.function.BiConsumer<R,R> combiner)
Performs a mutable
reduction operation on the elements of this reactiveStream.
|
<R,A> ReactiveSeq<R> |
collectStream(java.util.stream.Collector<? super T,A,R> collector) |
ReactiveSeq<T> |
combine(java.util.function.BiPredicate<? super T,? super T> predicate,
java.util.function.BinaryOperator<T> op)
Combine two adjacent elements in a traversable using the supplied BinaryOperator
This is a stateful grouping and reduction operation.
|
ReactiveSeq<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 <R> ReactiveSeq<R> |
createSeq(java.util.stream.Stream<R> rStream) |
ReactiveSeq<T> |
cycle()
Convert to a Stream with the values infinitely cycled
|
ReactiveSeq<T> |
cycle(long times)
Convert to a Stream with the values repeated specified times
|
ReactiveSeq<T> |
distinct() |
<U> ReactiveSeq<T> |
distinct(java.util.function.Function<? super T,? extends U> keyExtractor) |
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> |
duplicate()
Duplicate a Stream, buffers intermediate values, leaders may change
positions so a limit can be safely applied to the leading reactiveStream.
|
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> |
duplicate(java.util.function.Supplier<java.util.Deque<T>> bufferFactory) |
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() |
static <T> java.util.Optional<T> |
findFirstCallAll(ReactiveStreamX<T> stream) |
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>> fn) |
<R> ReactiveSeq<R> |
flatMapP(int maxConcurency,
java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> fn) |
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.
|
void |
forEachAsync(java.util.function.Consumer<? super T> action)
A potentially non-blocking analog of
ReactiveSeq.forEach(java.util.function.Consumer<? super T>). |
void |
forEachOrdered(java.util.function.Consumer<? super T> consumer) |
<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.
|
<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.
|
<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.
|
java.lang.String |
format() |
ReactiveStreamX.Type |
getType() |
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>> |
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> |
mergeP(org.reactivestreams.Publisher<T>... publishers)
A potentially asynchronous merge 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#mergePublisher(Collection, QueueFactory)
method to forEachAsync asynchronously also. |
ReactiveSeq<T> |
mergeP(QueueFactory<T> factory,
org.reactivestreams.Publisher<T>... publishers)
A potentially asynchronous merge operation where data from each publisher may arrive out of order (if publishers
are configured to publish asynchronously.
|
ListX<ReactiveSeq<T>> |
multicast(int num)
Broadcast the contents of this Stream to multiple downstream Streams (determined by supplier parameter).
|
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
|
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> |
partition(java.util.function.Predicate<? super T> splitter)
Partition a Stream into two one a per element basis, based on predicate's
boolean value
|
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
|
org.jooq.lambda.tuple.Tuple4<ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>> |
quadruplicate()
Makes four copies of a Stream Buffers intermediate values, leaders may
change positions so a limit can be safely applied to the leading reactiveStream.
|
org.jooq.lambda.tuple.Tuple4<ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>> |
quadruplicate(java.util.function.Supplier<java.util.Deque<T>> bufferFactory) |
<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> U |
reduce(U identity,
java.util.function.BiFunction<U,? super T,U> accumulator,
java.util.function.BinaryOperator<U> combiner)
An equivalent function to
Stream.reduce(Object, BiFunction, BinaryOperator) |
ReactiveSeq<T> |
reduceAll(T identity,
java.util.function.BinaryOperator<T> accumulator) |
ReactiveSeq<T> |
reverse()
Potentially efficient Stream reversal.
|
ReactiveSeq<T> |
scanLeft(Monoid<T> monoid)
Scan left using supplied Monoid
|
<U> ReactiveSeq<U> |
scanLeft(U seed,
java.util.function.BiFunction<? super U,? super T,? extends U> function)
Scan left
|
HotStream<T> |
schedule(java.lang.String cron,
java.util.concurrent.ScheduledExecutorService ex)
Execute this Stream on a schedule
|
HotStream<T> |
scheduleFixedDelay(long delay,
java.util.concurrent.ScheduledExecutorService ex)
Execute this Stream on a schedule
|
HotStream<T> |
scheduleFixedRate(long rate,
java.util.concurrent.ScheduledExecutorService ex)
Execute this Stream on a schedule
|
Maybe<T> |
single()
//Maybe[1]
ReactiveSeq.of(1).singleUnsafe();
//Maybe.none
ReactiveSeq.of().singleUnsafe();
//Maybe.none
ReactiveSeq.of(1,2,3).singleUnsafe();
|
Maybe<T> |
single(java.util.function.Predicate<? super T> predicate) |
T |
singleUnsafe()
//1
ReactiveSeq.of(1).singleUsafe();
//UnsupportedOperationException
ReactiveSeq.of().singleUnsafe();
//UnsupportedOperationException
ReactiveSeq.of(1,2,3).singleUnsafe();
|
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> |
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
|
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> |
splitAt(int where)
Split at supplied location
|
org.jooq.lambda.tuple.Tuple2<java.util.Optional<T>,ReactiveSeq<T>> |
splitAtHead()
Split a Stream at it's head (similar to headAndTail)
|
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> |
splitBy(java.util.function.Predicate<T> splitter)
Split reactiveStream at point where predicate no longer holds
|
java.util.Spliterator<T> |
spliterator()
Returns a spliterator for the elements of this reactiveStream.
|
void |
subscribe(org.reactivestreams.Subscriber<? super T> sub) |
Maybe<T> |
takeOne() |
org.jooq.lambda.tuple.Tuple3<ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>> |
triplicate()
Triplicates a Stream Buffers intermediate values, leaders may change
positions so a limit can be safely applied to the leading reactiveStream.
|
org.jooq.lambda.tuple.Tuple3<ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>> |
triplicate(java.util.function.Supplier<java.util.Deque<T>> bufferFactory) |
<T> ReactiveSeq<T> |
unit(T unit) |
<U> ReactiveSeq<U> |
unitIterator(java.util.Iterator<U> it)
Create an IterableFunctor instance of the same type from an Iterator
|
java.util.stream.Stream<T> |
unwrapStream() |
<R> R |
visit(java.util.function.Function<? super ReactiveSeq<T>,? extends R> sync,
java.util.function.Function<? super ReactiveSeq<T>,? extends R> reactiveStreams,
java.util.function.Function<? super ReactiveSeq<T>,? extends R> asyncNoBackPressure) |
<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
|
<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
|
<U,R> ReactiveSeq<R> |
zipLatest(org.reactivestreams.Publisher<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends R> zipper) |
<U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
zipS(java.util.stream.Stream<? extends U> other)
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
|
anyM, close, debounce, endsWith, endsWithIterable, findAny, firstValue, fixedDelay, flatMapBufferedReader, flatMapCharSequence, flatMapCompletableFuture, flatMapFile, flatMapOptional, flatMapStream, flatMapToDouble, flatMapToInt, flatMapToLong, flatMapURL, foldLeft, foldLeft, foldLeftMapToType, foldRight, foldRight, foldRight, foldRightMapToType, headAndTail, isParallel, jitter, join, join, join, mapReduce, mapReduce, mapToDouble, mapToInt, mapToLong, max, maxBy, min, minBy, noneMatch, onClose, onePer, parallel, 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, cast, collectAll, combinations, combinations, combinationsT, combinationsT, combine, concat, concat, concat, concat, concatDoubles, concatInts, concatLongs, coproduct, crossJoin, cycle, cycleUntil, cycleWhile, deferred, deferredI, deferredP, deleteBetween, doubles, drop, dropRight, dropUntil, dropWhile, 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, fromCharSequence, fromDoubleStream, fromIntStream, fromIterable, fromIterator, fromList, fromLongStream, fromPublisher, fromSpliterator, fromStream, generate, generate, get, groupBy, grouped, grouped, groupedUntil, groupedUntil, hotStream, insertAt, insertAtS, intersperse, ints, isEmpty, isReplayable, iterate, iterate, jool, kindCokleisli, kindKleisli, liftM, limitDouble, limitInts, limitLongs, limitUntilClosed, longs, mapDoubles, mapInts, mapLongs, mapM, merge, narrowK, nested, notNull, of, of, ofDoubles, ofInts, ofLongs, ofNullable, ofType, oneShotList, oneShotStream, parallel, parallel, parallelFanOut, parallelFanOut, parallelFanOut, parallelFanOutZipIn, parallelFanOutZipIn, parallelFanOutZipIn, pausableHotStream, peek, permutations, permutationsT, primedHotStream, primedPausableHotStream, print, print, printErr, printOut, product, product, publishTo, publishTo, range, range, rangeLong, rangeLong, reactiveSeq, reduce, remove, removeAll, removeAllI, removeAllS, retainAll, retainAllI, retainAllS, retry, retry, reversedListOf, reversedOf, scanRight, scanRight, seq, shuffle, shuffle, size, skipDoubles, skipInts, skipLongs, skipUntil, skipUntilClosed, slice, sliding, sorted, sorted, sorted, subStream, tailRec, take, takeRight, takeUntil, takeWhile, timestamp, trampoline, unfold, unzip, unzip3, unzip4, widen, zip, zip, zip, zip3, zip4, zipP, zipP, zipWith, zipWithIndex, zipWithP, zipWithSasFunction, foldFuture, foldLazy, foldTry, runFuture, runLazy, toListX, toSetX, visitcollectors, commonPrefix, commonSuffix, count, countDistinct, countDistinct, countDistinctBy, countDistinctBy, mode, sum, sumDouble, sumInt, sumLong, to, toMap, toMap, toString, toStringtraversablegroupedStatefullyUntilT, groupedT, groupedUntilT, groupedWhileT, slidingT, slidingTpublic ReactiveStreamX(Operator<T> source, ReactiveStreamX.Type async)
public ReactiveStreamX.Type getType()
public ReactiveSeq<T> reverse()
Traversable assertThat( of(1, 2, 3).reverse().toList(),
equalTo(asList(3, 2, 1))); public ReactiveSeq<T> combine(java.util.function.BiPredicate<? super T,? super T> predicate, java.util.function.BinaryOperator<T> op)
Traversable
ReactiveSeq.of(1,1,2,3)
.combine((a, b)->a.equals(b),SemigroupK.intSum)
.listX()
//ListX(3,4)
predicate - Test to see if two neighbours should be joined. The first parameter to the bi-predicate is the currently
accumulated result and the second is the next elementop - BinaryOperator to combine neighbourspublic ReactiveSeq<T> reduceAll(T identity, java.util.function.BinaryOperator<T> accumulator)
public <R,A> ReactiveSeq<R> collectStream(java.util.stream.Collector<? super T,A,R> collector)
public 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 Maybe<T> findOne()
ReactiveSeqpublic Either<java.lang.Throwable,T> findFirstOrError()
ReactiveSeqpublic final java.util.Optional<T> findFirst()
ReactiveSeq.of(1,2,3,4,5).filter(it -> it <3).findFirst().get();
//3
(deterministic)public static final <T> java.util.Optional<T> findFirstCallAll(ReactiveStreamX<T> stream)
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 ReactiveSeq<T> scanLeft(Monoid<T> monoid)
ReactiveSeq
assertEquals(asList("", "a", "ab", "abc"),ReactiveSeq.of("a", "b", "c")
.scanLeft(Reducers.toString("")).toList());
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 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> 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 java.lang.String format()
public 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 <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 final <R> ReactiveSeq<R> flatMapP(java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> fn)
public final <R> ReactiveSeq<R> flatMapP(int maxConcurency, java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> fn)
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 java.util.Spliterator<T> spliterator()
ReactiveSeq
This is a terminal operation.
public java.util.stream.Stream<T> unwrapStream()
unwrapStream in class BaseExtendedStream<T>protected <R> ReactiveSeq<R> createSeq(java.util.stream.Stream<R> rStream)
createSeq in class BaseExtendedStream<T>public <R> ReactiveSeq<R> mapLazyFn(java.util.function.Supplier<java.util.function.Function<? super T,? extends R>> fn)
mapLazyFn in class BaseExtendedStream<T>public final ReactiveSeq<T> filterLazyPredicate(java.util.function.Supplier<java.util.function.Predicate<? super T>> fn)
filterLazyPredicate in class BaseExtendedStream<T>public ReactiveSeq<T> changes()
public <U,R> ReactiveSeq<R> zipLatest(org.reactivestreams.Publisher<? extends U> other, java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
public void forEachAsync(java.util.function.Consumer<? super T> action)
ReactiveSeqReactiveSeq.forEach(java.util.function.Consumer<? super T>).
For push based reactiveBuffer Stream types (created via Spouts or FutureStream)action - a
non-interfering action to perform on the elementspublic 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 long count()
ReactiveSeq
return mapToLong(e -> 1L).sum();
This is a terminal operation.
public <U> ReactiveSeq<U> unitIterator(java.util.Iterator<U> it)
Traversable
ReactiveSeq<Integer> newSeq = seq.unitIterable(myIterator);
it - Iterator to create new IterableFunctor frompublic ReactiveSeq<T> backpressureAware()
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 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>> 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> 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> complete(java.lang.Runnable fn)
ReactiveSeqfn - Function that accepts and returns completed valuepublic 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 void forEachOrdered(java.util.function.Consumer<? super T> consumer)
forEachOrdered in interface java.util.stream.Stream<T>forEachOrdered in class BaseExtendedStream<T>public <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!
consumer - To accept incoming events from the Streampublic <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!
consumer - To accept incoming elements from the StreamconsumerError - To accept incoming processing errors from the Streampublic <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!
consumer - 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> 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 ReactiveSeq<T> mergeP(QueueFactory<T> factory, org.reactivestreams.Publisher<T>... publishers)
ReactiveSeqQueueFactories
Push based reactiveBuffer-streams signal demand via their subscription.public ReactiveSeq<T> mergeP(org.reactivestreams.Publisher<T>... publishers)
ReactiveSeqIterableFunctor#mergePublisher(Collection, QueueFactory)
method to forEachAsync asynchronously also. Max concurrency is determined by the publishers toX size, along with a default limit of 5k queued values before
backpressure is applied.publishers - Publishers to mergepublic <T> ReactiveSeq<T> unit(T unit)
public <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 HotStream<T> schedule(java.lang.String cron, java.util.concurrent.ScheduledExecutorService ex)
ReactiveSeq
//run at 8PM every night
ReactiveSeq.generate(()->"next job:"+formatDate(new Date()))
.map(this::processJob)
.schedule("0 20 * * *",Executors.newScheduledThreadPool(1));
Connect to the Scheduled Stream
HotStream<Data> dataStream = ReactiveSeq.generate(() -> "next job:" + formatDate(new Date())).map(this::processJob)
.schedule("0 20 * * *", Executors.newScheduledThreadPool(1));
data.connect().forEach(this::logToDB);
cron - Expression that determines when each job will runex - ScheduledExecutorServicepublic HotStream<T> scheduleFixedDelay(long delay, java.util.concurrent.ScheduledExecutorService ex)
ReactiveSeq
//run every 60 seconds after last job completes
ReactiveSeq.generate(()->"next job:"+formatDate(new Date()))
.map(this::processJob)
.scheduleFixedDelay(60_000,Executors.newScheduledThreadPool(1));
Connect to the Scheduled Stream
HotStream<Data> dataStream = ReactiveSeq.generate(() -> "next job:" + formatDate(new Date())).map(this::processJob)
.scheduleFixedDelay(60_000, Executors.newScheduledThreadPool(1));
data.connect().forEach(this::logToDB);
delay - Between last element completes passing through the Stream
until the next one startsex - ScheduledExecutorServicepublic HotStream<T> scheduleFixedRate(long rate, java.util.concurrent.ScheduledExecutorService ex)
ReactiveSeq
//run every 60 seconds
ReactiveSeq.generate(()->"next job:"+formatDate(new Date()))
.map(this::processJob)
.scheduleFixedRate(60_000,Executors.newScheduledThreadPool(1));
Connect to the Scheduled Stream
HotStream<Data> dataStream = ReactiveSeq.generate(() -> "next job:" + formatDate(new Date())).map(this::processJob)
.scheduleFixedRate(60_000, Executors.newScheduledThreadPool(1));
data.connect().forEach(this::logToDB);
rate - Time in millis between job runsex - ScheduledExecutorServicepublic 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 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 ReactiveSeq<T> cycle()
ReactiveSeq
ReactiveSeq.of(1).cycle().limit(6).toList());
//List[1, 1, 1, 1, 1,1]
public org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> duplicate()
ReactiveSeq
Tuple2<ReactiveSeq<Integer>, ReactiveSeq<Integer>> copies = of(1, 2, 3, 4, 5, 6)
.duplicate();
assertTrue(copies.v1.anyMatch(i > i == 2));
assertTrue(copies.v2.anyMatch(i > i == 2));
public org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> duplicate(java.util.function.Supplier<java.util.Deque<T>> bufferFactory)
public org.jooq.lambda.tuple.Tuple3<ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>> triplicate()
ReactiveSeq
Tuple3<ReactiveSeq<Tuple3<T1, T2, T3>>, ReactiveSeq<Tuple3<T1, T2, T3>>, ReactiveSeq<Tuple3<T1, T2, T3>>> Tuple3 = sequence.triplicate();
public org.jooq.lambda.tuple.Tuple3<ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>> triplicate(java.util.function.Supplier<java.util.Deque<T>> bufferFactory)
public ListX<ReactiveSeq<T>> multicast(int num)
ReactiveSeqReactiveSeq.duplicate()
ReactiveSeq#triplate
ReactiveSeq.quadruplicate()
Which buffer all Stream types and produce a synchronous downstream stream.num - Number of downstream Streams to multicast topublic org.jooq.lambda.tuple.Tuple4<ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>> quadruplicate()
ReactiveSeq
Tuple4<ReactiveSeq<Tuple4<T1, T2, T3, T4>>,
ReactiveSeq<Tuple4<T1, T2, T3, T4>>,
ReactiveSeq<Tuple4<T1, T2, T3, T4>>,
ReactiveSeq<Tuple4<T1, T2, T3, T4>>> quad = sequence.quadruplicate();
public org.jooq.lambda.tuple.Tuple4<ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>> quadruplicate(java.util.function.Supplier<java.util.Deque<T>> bufferFactory)
public org.jooq.lambda.tuple.Tuple2<java.util.Optional<T>,ReactiveSeq<T>> splitAtHead()
ReactiveSeq
ReactiveSeq.of(1,2,3)
.splitAtHead()
//Optional[1], ReactiveSeq[2,3]
public org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> splitAt(int where)
ReactiveSeq
ReactiveSeq.of(1,2,3)
.splitAt(1)
//ReactiveSeq[1], ReactiveSeq[2,3]
public org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> splitBy(java.util.function.Predicate<T> splitter)
ReactiveSeq
ReactiveSeq.of(1, 2, 3, 4, 5, 6).splitBy(i->i<4)
//ReactiveSeq[1,2,3] ReactiveSeq[4,5,6]
public org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> partition(java.util.function.Predicate<? super T> splitter)
ReactiveSeq
ReactiveSeq.of(1, 2, 3, 4, 5, 6).partition(i -> i % 2 != 0)
//ReactiveSeq[1,3,5], ReactiveSeq[2,4,6]
public <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> zipS(java.util.stream.Stream<? extends U> other)
ReactiveSeq
List<Tuple2<Integer, String>> list = of(1, 2).zip(of("a", "b", "c", "d")).toList();
// [[1,"a"],[2,"b"]]
other - Stream to combine withpublic <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> 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 ReactiveSeq<T> cycle(long times)
ReactiveSeq
ReactiveSeq.of(1,2,2)
.cycle(3)
.collect(CyclopsCollectors.toList());
//List[1,2,2,1,2,2,1,2,2]
times - Times values should be repeated within a Streampublic <U> U reduce(U identity,
java.util.function.BiFunction<U,? super T,U> accumulator,
java.util.function.BinaryOperator<U> combiner)
FoldsStream.reduce(Object, BiFunction, BinaryOperator)reduce in interface Folds<T>reduce in interface ReactiveSeq<T>reduce in interface java.util.stream.Stream<T>reduce in class BaseExtendedStream<T>public 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,A> R collect(java.util.stream.Collector<? super T,A,R> collector)
ReactiveSeqCollector. A Collector
encapsulates the function used as arguments to
ReactiveSeq.collect(Supplier, BiConsumer, BiConsumer), allowing for reuse of
toX strategies and composition of collect operations such as
multiple-level grouping or partitioning.
If the reactiveStream is parallel, and the Collector
is concurrent, and
lazy the reactiveStream is unordered or the collector is
unordered,
applyHKT a concurrent reduction will be performed (see Collector for
details on concurrent reduction.)
This is a terminal operation.
When executed in parallel, multiple intermediate results may be
instantiated, populated, and merged so as to maintain isolation of
mutable data structures. Therefore, even when executed in parallel
with non-thread-safe data structures (such as ArrayList), no
additional synchronization is needed for a parallel reduction.
collect in interface CyclopsCollectable<T>collect in interface ReactiveSeq<T>collect in interface java.util.stream.Stream<T>collect in class BaseExtendedStream<T>collector - the Collector describing the reductionReactiveSeq.collect(Supplier, BiConsumer, BiConsumer),
Collectorspublic <R> R collect(java.util.function.Supplier<R> supplier,
java.util.function.BiConsumer<R,? super T> accumulator,
java.util.function.BiConsumer<R,R> combiner)
ReactiveSeqArrayList, and elements are incorporated by updating
the state of the result rather than by replacing the result. This
produces a result equivalent to:
R result = supplier.get();
for (T element : this reactiveStream)
accumulator.accept(result, element);
return result;
Like ReactiveSeq.reduce(Object, BinaryOperator), collect operations
can be parallelized without requiring additional synchronization.
This is a terminal operation.
collect in interface ReactiveSeq<T>collect in interface java.util.stream.Stream<T>collect in class BaseExtendedStream<T>supplier - a function that creates a new result container. For a
parallel execution, this function may be called
multiple times and must return a fresh value each time.accumulator - an associative,
non-interfering,
stateless
function for incorporating an additional element into a resultcombiner - an associative,
non-interfering,
stateless
function for combining two values, which must be
compatible with the accumulator functionpublic 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 boolean allMatch(java.util.function.Predicate<? super T> c)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3,4,5).allMatch(it-> it>0 && it <6),equalTo(true));
allMatch in interface CyclopsCollectable<T>allMatch in interface ReactiveSeq<T>allMatch in interface java.util.stream.Stream<T>allMatch in class BaseExtendedStream<T>c - Predicate to check if all matchpublic final boolean anyMatch(java.util.function.Predicate<? super T> c)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3,4,5).anyMatch(it-> it.equals(3)),equalTo(true));
anyMatch in interface CyclopsCollectable<T>anyMatch in interface ReactiveSeq<T>anyMatch in interface java.util.stream.Stream<T>anyMatch in class BaseExtendedStream<T>c - Predicate to check if any matchpublic <R> R visit(java.util.function.Function<? super ReactiveSeq<T>,? extends R> sync, java.util.function.Function<? super ReactiveSeq<T>,? extends R> reactiveStreams, java.util.function.Function<? super ReactiveSeq<T>,? extends R> asyncNoBackPressure)
public T singleUnsafe()
ReactiveSeq
//1
ReactiveSeq.of(1).singleUsafe();
//UnsupportedOperationException
ReactiveSeq.of().singleUnsafe();
//UnsupportedOperationException
ReactiveSeq.of(1,2,3).singleUnsafe();
public Maybe<T> single()
ReactiveSeq
//Maybe[1]
ReactiveSeq.of(1).singleUnsafe();
//Maybe.none
ReactiveSeq.of().singleUnsafe();
//Maybe.none
ReactiveSeq.of(1,2,3).singleUnsafe();