public class ReactiveSeqImpl<T> extends java.lang.Object implements Unwrapable, ReactiveSeq<T>, java.lang.Iterable<T>
| Constructor and Description |
|---|
ReactiveSeqImpl(java.util.stream.Stream<T> stream) |
ReactiveSeqImpl(java.util.stream.Stream<T> stream,
ReversableSpliterator rev) |
| 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
|
AnyMSeq<T> |
anyM() |
boolean |
anyMatch(java.util.function.Predicate<? super T> c)
True if a single element matches when Monad converted to a Stream
|
ReactiveSeq<T> |
append(T... values)
Append values to the end of this ReactiveSeq
|
ReactiveSeq<T> |
append(T value) |
ReactiveSeq<T> |
appendStream(java.util.stream.Stream<T> stream)
Append Stream to this ReactiveSeq
|
<U> ReactiveSeq<U> |
cast(java.lang.Class<? extends U> type)
Cast all elements in a stream to a given type, possibly throwing a
ClassCastException. |
void |
close() |
<R,A> R |
collect(java.util.stream.Collector<? super T,A,R> 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) |
org.jooq.lambda.Collectable<T> |
collectable()
Narrow this class to a Collectable
|
ReactiveSeq<T> |
concat(java.util.stream.Stream<? extends T> other) |
ReactiveSeq<T> |
concat(T... other) |
ReactiveSeq<T> |
concat(T other) |
long |
count() |
ReactiveSeq<T> |
cycle()
Convert to a Stream with the values infinitely cycled
|
ReactiveSeq<T> |
cycle(int times)
Convert to a Stream with the values repeated specified times
|
ReactiveSeq<T> |
cycle(Monoid<T> m,
int times)
Convert to a Stream with the result of a reduction operation repeated
specified times
|
ReactiveSeq<T> |
cycleUntil(java.util.function.Predicate<? super T> predicate)
Repeat in a Stream until specified predicate holds
|
ReactiveSeq<T> |
cycleWhile(java.util.function.Predicate<? super T> predicate)
Repeat in a Stream while specified predicate holds
|
ReactiveSeq<T> |
debounce(long time,
java.util.concurrent.TimeUnit t)
Allow one element through per time period, drop all other elements in
that time period
|
ReactiveSeq<T> |
deleteBetween(int start,
int end)
Delete elements between given indexes in a Stream
|
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>> |
duplicateSequence()
Duplicate a Stream, buffers intermediate values, leaders may change
positions so a limit can be safely applied to the leading stream.
|
boolean |
endsWith(java.util.stream.Stream<T> iterable)
assertTrue(ReactiveSeq.of(1,2,3,4,5,6)
.endsWith(Stream.of(5,6)));
|
boolean |
endsWithIterable(java.lang.Iterable<T> iterable)
assertTrue(ReactiveSeq.of(1,2,3,4,5,6)
.endsWith(Arrays.asList(5,6)));
|
ReactiveSeq<T> |
filter(java.util.function.Predicate<? super T> fn)
Keep only elements for which the supplied predicates hold
e.g.
|
java.util.Optional<T> |
findAny() |
java.util.Optional<T> |
findFirst() |
T |
firstValue()
assertThat(ReactiveSeq.of(1,2,3,4)
.map(u->{throw new RuntimeException();})
.recover(e->"hello")
.firstValue(),equalTo("hello"));
|
ReactiveSeq<T> |
fixedDelay(long l,
java.util.concurrent.TimeUnit unit)
emit elements after a fixed delay
|
<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<? extends R>> fn)
Allows flatMap return type to be any Monad type
|
ReactiveSeq<java.lang.String> |
flatMapBufferedReader(java.util.function.Function<? super T,java.io.BufferedReader> fn) |
ReactiveSeq<java.lang.Character> |
flatMapCharSequence(java.util.function.Function<? super T,java.lang.CharSequence> fn) |
<R> ReactiveSeq<R> |
flatMapCompletableFuture(java.util.function.Function<? super T,java.util.concurrent.CompletableFuture<? extends R>> fn) |
ReactiveSeq<java.lang.String> |
flatMapFile(java.util.function.Function<? super T,java.io.File> fn) |
<R> ReactiveSeq<R> |
flatMapIterable(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> |
flatMapOptional(java.util.function.Function<? super T,java.util.Optional<? extends R>> fn) |
<R> ReactiveSeq<R> |
flatMapStream(java.util.function.Function<? super T,java.util.stream.BaseStream<? extends R,?>> fn)
flatMap operation
|
java.util.stream.DoubleStream |
flatMapToDouble(java.util.function.Function<? super T,? extends java.util.stream.DoubleStream> mapper) |
java.util.stream.IntStream |
flatMapToInt(java.util.function.Function<? super T,? extends java.util.stream.IntStream> mapper) |
java.util.stream.LongStream |
flatMapToLong(java.util.function.Function<? super T,? extends java.util.stream.LongStream> mapper) |
ReactiveSeq<java.lang.String> |
flatMapURL(java.util.function.Function<? super T,java.net.URL> fn) |
<T1> ReactiveSeq<T1> |
flatten()
join / flatten one level of a nested hierarchy
|
T |
foldLeft(Monoid<T> reducer) |
T |
foldLeft(T identity,
java.util.function.BinaryOperator<T> accumulator) |
<T> T |
foldLeftMapToType(Reducer<T> reducer) |
T |
foldRight(Monoid<T> reducer)
ReactiveSeq.of("a","b","c").foldRight(Reducers.toString(""));
// "cab"
|
T |
foldRight(T identity,
java.util.function.BinaryOperator<T> accumulator)
Immutable reduction from right to left
|
<U> U |
foldRight(U seed,
java.util.function.BiFunction<? super T,? super U,? extends U> function)
Immutable reduction from right to left
|
<T> T |
foldRightMapToType(Reducer<T> reducer)
Attempt to map this Monad to the same type as the supplied Monoid (using
mapToType on the monoid interface) Then use Monoid to reduce values
|
void |
forEach(java.util.function.Consumer<? super T> action) |
<X extends java.lang.Throwable> |
forEachEvent(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.
|
void |
forEachOrdered(java.util.function.Consumer<? super T> action) |
<X extends java.lang.Throwable> |
forEachWithError(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> |
forEachX(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> |
forEachXEvents(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.
|
<X extends java.lang.Throwable> |
forEachXWithError(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.
|
java.lang.String |
format() |
FutureOperations<T> |
futureOperations(java.util.concurrent.Executor exec)
Access asynchronous terminal operations (each returns a Future)
|
<K> MapX<K,java.util.List<T>> |
groupBy(java.util.function.Function<? super T,? extends K> classifier)
Use classifier function to group elements in this Sequence into a Map
|
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 collection 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 collection created by the supplied factory
|
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 collection created by the supplied factory
|
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.
|
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
|
HeadAndTail<T> |
headAndTail()
extract head and tail together, where head is expected to be present
Example :
|
HotStream<T> |
hotStream(java.util.concurrent.Executor e)
Turns this ReactiveSeq into a HotStream, a connectable Stream, being executed on a thread on the
supplied executor, that is producing data.
|
ReactiveSeq<T> |
insertAt(int pos,
T... values)
Insert data into a stream at given position
|
ReactiveSeq<T> |
insertStreamAt(int pos,
java.util.stream.Stream<T> stream)
Insert a Stream into the middle of this stream at the specified position
|
ReactiveSeq<T> |
intersperse(T value)
Returns a stream with a given value interspersed between any two values
of this stream.
|
boolean |
isParallel() |
java.util.Iterator<T> |
iterator() |
ReactiveSeq<T> |
jitter(long l)
Introduce a random jitter / time delay between the emission of elements
|
java.lang.String |
join()
assertEquals("123".length(),ReactiveSeq.of(1, 2, 3).join().length());
|
java.lang.String |
join(java.lang.String sep)
assertEquals("1, 2, 3".length(), ReactiveSeq.of(1, 2, 3).join(", ").length());
|
java.lang.String |
join(java.lang.String sep,
java.lang.String start,
java.lang.String end)
assertEquals("^1|2|3$".length(), of(1, 2, 3).join("|", "^", "$").length());
|
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
|
<R> ReactiveSeq<R> |
map(java.util.function.Function<? super T,? extends R> fn)
Transform this functor using the supplied transformation function
|
<R> R |
mapReduce(java.util.function.Function<? super T,? extends R> mapper,
Monoid<R> reducer)
Attempt to map this Monad to the same type as the supplied Monoid, using
supplied function Then use Monoid to reduce values
|
<R> R |
mapReduce(Reducer<R> reducer)
Attempt to map this Sequence to the same type as the supplied Monoid
(Reducer) Then use Monoid to reduce values
|
java.util.stream.DoubleStream |
mapToDouble(java.util.function.ToDoubleFunction<? super T> mapper) |
java.util.stream.IntStream |
mapToInt(java.util.function.ToIntFunction<? super T> mapper) |
java.util.stream.LongStream |
mapToLong(java.util.function.ToLongFunction<? super T> mapper) |
java.util.Optional<T> |
max(java.util.Comparator<? super T> comparator) |
<C extends java.lang.Comparable<? super C>> |
maxBy(java.util.function.Function<? super T,? extends C> f) |
java.util.Optional<T> |
min(java.util.Comparator<? super T> comparator) |
<U extends java.lang.Comparable<? super U>> |
minBy(java.util.function.Function<? super T,? extends U> function) |
boolean |
noneMatch(java.util.function.Predicate<? super T> c) |
<U> ReactiveSeq<U> |
ofType(java.lang.Class<? extends U> type)
Keep only those elements in a stream that are of a given type.
|
ReactiveSeq<T> |
onClose(java.lang.Runnable closeHandler) |
ReactiveSeq<T> |
onEmpty(T value)
If this Container instance is empty, create a new instance containing the provided value
|
ReactiveSeq<T> |
onEmptyGet(java.util.function.Supplier<? extends T> supplier)
If this Container instance is empty, create a new instance containing the value returned from the provided Supplier
|
<X extends java.lang.Throwable> |
onEmptyThrow(java.util.function.Supplier<? extends X> supplier)
If this container instance is empty, throw the exception returned by the provided Supplier
|
ReactiveSeq<T> |
onePer(long time,
java.util.concurrent.TimeUnit t)
emit one element per time period
|
ReactiveSeq<T> |
parallel() |
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> |
partitionSequence(java.util.function.Predicate<T> splitter)
Partition a Stream into two one a per element basis, based on predicate's
boolean value
|
PausableHotStream<T> |
pausableHotStream(java.util.concurrent.Executor e)
Turns this ReactiveSeq into a HotStream, a connectable & pausable Stream, being executed on a thread on the
supplied executor, that is producing data.
|
ReactiveSeq<T> |
peek(java.util.function.Consumer<? super T> c)
Peek at the current value of this Functor, without transforming it
|
ReactiveSeq<T> |
prepend(T... values)
Prepend given values to the start of the Stream
|
ReactiveSeq<T> |
prepend(T value) |
ReactiveSeq<T> |
prependStream(java.util.stream.Stream<T> stream)
Prepend Stream to this ReactiveSeq
|
HotStream<T> |
primedHotStream(java.util.concurrent.Executor e)
Return a HotStream that will start emitting data when the first connecting Stream connects.
|
PausableHotStream<T> |
primedPausableHotStream(java.util.concurrent.Executor e)
Return a pausable HotStream that will start emitting data when the first connecting Stream connects.
|
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 stream.
|
<EX extends java.lang.Throwable> |
recover(java.lang.Class<EX> exceptionClass,
java.util.function.Function<EX,? extends T> fn)
Recover from a particular exception type
|
ReactiveSeq<T> |
recover(java.util.function.Function<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) |
ListX<T> |
reduce(java.lang.Iterable<? extends Monoid<T>> reducers)
Reduce with multiple reducers in parallel NB if this Monad is an Optional
[Arrays.asList(1,2,3)] reduce will operate on the Optional as if the list
was one value To reduce over the values on the list, called
streamedMonad() first.
|
T |
reduce(Monoid<T> reducer)
ReactiveSeq.of("hello","2","world","4").reduce(Reducers.toString(","));
//hello,2,world,4
|
ListX<T> |
reduce(java.util.stream.Stream<? extends Monoid<T>> reducers)
Reduce with multiple reducers in parallel NB if this Monad is an Optional
[Arrays.asList(1,2,3)] reduce will operate on the Optional as if the list
was one value To reduce over the values on the list, called
streamedMonad() first.
|
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)
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> |
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
|
ReactiveSeq<T> |
scanRight(Monoid<T> monoid)
Scan right
|
<U> ReactiveSeq<U> |
scanRight(U identity,
java.util.function.BiFunction<? super T,? super U,? extends U> combiner)
Scan right
|
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
|
ReactiveSeq<T> |
sequential() |
ReactiveSeq<T> |
shuffle() |
ReactiveSeq<T> |
shuffle(java.util.Random random) |
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(Collectors.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> |
slice(long from,
long to) |
ReactiveSeq<ListX<T>> |
sliding(int windowSize)
Create a sliding view over this Sequence
|
ReactiveSeq<ListX<T>> |
sliding(int windowSize,
int increment)
Create a sliding view over this Sequence
|
ReactiveSeq<T> |
sorted()
assertThat(ReactiveSeq.of(4,3,6,7)).sorted().toList(),equalTo(Arrays.asList(3,4,6,7))); |
ReactiveSeq<T> |
sorted(java.util.Comparator<? super T> c)
assertThat(ReactiveSeq.of(4,3,6,7).sorted((a,b) -> b-a).toList(),equalTo(Arrays.asList(7,6,4,3)));
|
<U extends java.lang.Comparable<? super U>> |
sorted(java.util.function.Function<? super T,? extends U> function) |
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> |
splitAt(int where)
Split at supplied location
|
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> |
splitBy(java.util.function.Predicate<T> splitter)
Split stream at point where predicate no longer holds
|
java.util.Spliterator<T> |
spliterator() |
org.jooq.lambda.tuple.Tuple2<java.util.Optional<T>,ReactiveSeq<T>> |
splitSequenceAtHead()
Split a Stream at it's head (similar to headAndTail)
|
boolean |
startsWith(java.util.stream.Stream<T> stream2)
assertTrue(ReactiveSeq.of(1,2,3,4).startsWith(Stream.of(1,2,3))) |
boolean |
startsWithIterable(java.lang.Iterable<T> iterable)
assertTrue(ReactiveSeq.of(1,2,3,4).startsWith(Arrays.asList(1,2,3)));
|
ReactiveSeq<T> |
stream()
Convert this ReactiveSeq into a Stream
|
void |
subscribe(org.reactivestreams.Subscriber<? super T> sub) |
java.lang.Object[] |
toArray() |
<A> A[] |
toArray(java.util.function.IntFunction<A[]> generator) |
<C extends java.util.Collection<T>> |
toCollection(java.util.function.Supplier<C> collectionFactory) |
CollectionX<T> |
toConcurrentLazyCollection()
Lazily converts this ReactiveSeq into a Collection.
|
Streamable<T> |
toConcurrentLazyStreamable()
Streamable<Integer> repeat = ReactiveSeq.of(1, 2, 3, 4, 5, 6).map(i -> i + 2).toConcurrentLazyStreamable();
assertThat(repeat.stream().toList(), equalTo(Arrays.asList(2, 4, 6, 8, 10, 12)));
assertThat(repeat.stream().toList(), equalTo(Arrays.asList(2, 4, 6, 8, 10, 12)));
|
CollectionX<T> |
toLazyCollection()
Lazily converts this ReactiveSeq into a Collection.
|
Streamable<T> |
toLazyStreamable() |
java.util.List<T> |
toList() |
java.util.Set<T> |
toSet() |
<T> java.util.stream.Stream<T> |
toStream()
Convert this ReactiveSeq into a Stream
|
Streamable<T> |
toStreamable()
Streamable<Integer> repeat = ReactiveSeq.of(1,2,3,4,5,6)
.map(i->i*2)
.toStreamable();
repeat.stream().toList(); //Arrays.asList(2,4,6,8,10,12));
repeat.stream().toList() //Arrays.asList(2,4,6,8,10,12));
|
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 stream.
|
<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
|
ReactiveSeq<T> |
unordered() |
<R> R |
unwrap()
Deprecated.
|
java.util.stream.Stream<T> |
unwrapStream() |
boolean |
xMatch(int num,
java.util.function.Predicate<? super T> c)
Check that there are specified number of matches of predicate in the
Stream
|
ReactiveSeq<T> |
xPer(int x,
long time,
java.util.concurrent.TimeUnit t)
emit x elements per time period
|
<U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
zip(org.jooq.lambda.Seq<? extends U> other)
Zip 2 streams into one
|
<U,R> ReactiveSeq<R> |
zip(org.jooq.lambda.Seq<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
Zip (combine) this Zippable with the supplied Seq, using the supplied combining function
|
<S> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,S>> |
zip(java.util.stream.Stream<? extends S> second)
Zip 2 streams into one
|
<S,U> ReactiveSeq<org.jooq.lambda.tuple.Tuple3<T,S,U>> |
zip3(java.util.stream.Stream<? extends S> second,
java.util.stream.Stream<? extends U> third)
zip 3 Streams into one
|
<T2,T3,T4> ReactiveSeq<org.jooq.lambda.tuple.Tuple4<T,T2,T3,T4>> |
zip4(java.util.stream.Stream<? extends T2> second,
java.util.stream.Stream<? extends T3> third,
java.util.stream.Stream<? extends T4> fourth)
zip 4 Streams into 1
|
<S,R> ReactiveSeq<R> |
zipStream(java.util.stream.BaseStream<? extends S,? extends java.util.stream.BaseStream<? extends S,?>> second,
java.util.function.BiFunction<? super T,? super S,? extends R> zipper)
Zip this Stream with another
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitap1, append, append, append, append, applicatives, avg, avg, avgDouble, avgInt, avgLong, coflatMap, combinations, combinations, combine, concat, concat, concat, count, countDistinct, countDistinct, countDistinctBy, countDistinctBy, crossApply, crossJoin, crossJoin, crossJoin, cycle, drop, dropRight, dropUntil, dropWhile, elapsed, elementAt, empty, fill, forEach2, forEach2, forEach3, forEach3, forEach4, forEach4, fromDoubleStream, fromIntStream, fromIterable, fromIterator, fromList, fromLongStream, fromPublisher, fromStream, generate, get, grouped, grouped, innerJoin, innerJoin, innerJoin, innerJoin, iterate, leftOuterJoin, leftOuterJoin, leftOuterJoin, leftOuterJoin, limitUntilClosed, limitWhileClosed, max, max, max, maxBy, median, median, medianBy, medianBy, min, min, min, minBy, mode, of, onEmptySwitch, outerApply, patternMatch, percentile, percentile, percentileBy, percentileBy, permutations, prepend, prepend, prepend, prepend, print, print, printErr, printOut, range, rangeLong, remove, retry, retry, reversedListOf, reversedOf, rightOuterJoin, rightOuterJoin, rightOuterJoin, single, single, singleOptional, size, skipUntilClosed, skipWhileClosed, sliding, sorted, subscriber, subStream, sum, sum, sumDouble, sumInt, sumLong, take, takeRight, takeUntil, takeWhile, timestamp, toList, toMap, toSet, toString, toString, trampoline, unfold, unzip, unzip3, unzip4, zip, zip, zip, zipWithIndexfilterNot, notNull, removeAll, removeAll, removeAll, removeAll, retainAll, retainAll, retainAll, retainAllgroupedStatefullyUntilT, groupedT, groupedUntilT, groupedWhileT, slidingT, slidingTfoldable, visitbitAnd, bitAnd, bitAndInt, bitAndLong, bitOr, bitOr, bitOrInt, bitOrLong, commonPrefix, commonSuffix, foldFuture, foldLazy, foldTry, maxAll, maxAll, maxAll, maxAll, maxAllBy, maxAllBy, minAll, minAll, minAll, minAll, minAllBy, minAllBy, modeAll, modeAllBy, modeBy, toMapwindow, window, window, window, window, window, window, window, window, window, window, window, window, window, window, window, window, window, window, window, window, window, windowcast, concat, concat, concat, concat, contains, containsAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, containsAny, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossApply, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, crossJoin, cycle, cycle, cycle, cycle, cycle, cycle, duplicate, duplicate, findFirst, findLast, findLast, findSingle, foldLeft, foldLeft, foldLeft, foldLeft, foldRight, foldRight, foldRight, generate, groupBy, groupBy, groupBy, groupBy, groupBy, grouped, grouped, grouped, grouped, grouped, grouped, indexOf, indexOf, intersperse, isEmpty, isNotEmpty, join, join, join, join, join, limit, limitUntil, limitUntilClosed, limitWhile, limitWhileClosed, ofType, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, outerApply, partition, partition, range, range, range, range, range, range, range, range, range, range, range, rangeClosed, rangeClosed, rangeClosed, rangeClosed, rangeClosed, rangeClosed, rangeClosed, rangeClosed, rangeClosed, rangeClosed, rangeClosed, rangeClosed, reverse, reverse, reverse, scanLeft, scanLeft, scanLeft, scanRight, scanRight, scanRight, seq, seq, seq, seq, seq, seq, seq, seq, seq, seq, seq, seq, seq, seq, seq, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, skip, skipUntil, skipUntilClosed, skipWhile, skipWhileClosed, slice, splitAt, splitAt, splitAtHead, splitAtHead, toCollection, toList, toMap, toMap, toSet, toString, toString, transform, unzip, unzip, unzip, unzip, unzip, unzip, unzip, unzip, unzip, unzip, unzip, unzip, window, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipAll, zipWithIndex, zipWithIndex, zipWithIndexap2, ap3, ap4, ap5flatMapPublisher, flatMapPublisher, flatMapPublisher, mergePublisher, mergePublisherlazyOperations, traversableseq, toCompletableFuture, toDequeX, toEvalAlways, toEvalLater, toEvalNow, toFutureStream, toFutureStream, toFutureW, toIor, toIorSecondary, toListX, toMapX, toMaybe, toOptional, toPBagX, toPMapX, toPOrderedSetX, toPQueueX, toPSetX, toPStackX, toPVectorX, toQueueX, toSetX, toSimpleReact, toSimpleReact, toSortedSetX, toTry, toValue, toValueMap, toValueSet, toXor, toXorSecondarypublic ReactiveSeqImpl(java.util.stream.Stream<T> stream)
public ReactiveSeqImpl(java.util.stream.Stream<T> stream, ReversableSpliterator rev)
public <U> U reduce(U identity,
java.util.function.BiFunction<U,? super T,U> accumulator)
FoldableStream.reduce(Object, BinaryOperator)reduce in interface Foldable<T>identity - Identity value for the combiner function (leaves the input unchanged)accumulator - Combiner functionpublic <T> ReactiveSeq<T> unit(T unit)
public 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);
public 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);
scheduleFixedDelay in interface ReactiveSeq<T>scheduleFixedDelay in interface Foldable<T>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);
scheduleFixedRate in interface ReactiveSeq<T>scheduleFixedRate in interface Foldable<T>rate - Time in millis between job runsex - ScheduledExecutorService@Deprecated public final <R> R unwrap()
Unwrapableunwrap in interface ReactiveSeq<T>unwrap in interface Unwrapablepublic final <T1> ReactiveSeq<T1> flatten()
ReactiveSeq
ReactiveSeq.of(Arrays.asList(1,2)).flatten();
//stream of (1, 2);
flatten in interface ReactiveSeq<T>public final java.util.stream.Stream<T> unwrapStream()
public final ReactiveSeq<T> cycle(int times)
ReactiveSeq
ReactiveSeq.of(1,2,2)
.cycle(3)
.collect(Collectors.toList());
//List[1,2,2,1,2,2,1,2,2]
cycle in interface ReactiveSeq<T>cycle in interface Traversable<T>times - Times values should be repeated within a Streampublic final ReactiveSeq<T> cycle()
ReactiveSeq
ReactiveSeq.of(1).cycle().limit(6).toList());
//List[1, 1, 1, 1, 1,1]
cycle in interface ReactiveSeq<T>cycle in interface org.jooq.lambda.Seq<T>public final org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> duplicateSequence()
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));
duplicateSequence in interface ReactiveSeq<T>public final 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();
triplicate in interface ReactiveSeq<T>public final 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();
quadruplicate in interface ReactiveSeq<T>public final org.jooq.lambda.tuple.Tuple2<java.util.Optional<T>,ReactiveSeq<T>> splitSequenceAtHead()
ReactiveSeq
ReactiveSeq.of(1,2,3)
.splitAtHead()
//Optional[1], ReactiveSeq[2,3]
splitSequenceAtHead in interface ReactiveSeq<T>public final 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]
splitAt in interface ReactiveSeq<T>public final 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]
splitBy in interface ReactiveSeq<T>public final org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> partitionSequence(java.util.function.Predicate<T> splitter)
ReactiveSeq
ReactiveSeq.of(1, 2, 3, 4, 5, 6).partition(i -> i % 2 != 0)
//ReactiveSeq[1,3,5], ReactiveSeq[2,4,6]
partitionSequence in interface ReactiveSeq<T>public final ReactiveSeq<T> cycle(Monoid<T> m, int times)
ReactiveSeq
List<Integer> list = ReactiveSeq.of(1,2,2))
.cycle(Reducers.toCountInt(),3)
.collect(Collectors.toList());
//List[3,3,3];
cycle in interface ReactiveSeq<T>cycle in interface Traversable<T>m - Monoid to be used in reductiontimes - Number of times value should be repeatedpublic final ReactiveSeq<T> cycleWhile(java.util.function.Predicate<? super T> predicate)
ReactiveSeq
MutableInt count = MutableInt.of(0);
ReactiveSeq.of(1, 2, 2).cycleWhile(next -> count++ < 6)
.collect(Collectors.toList());
// List(1,2,2,1,2,2)
cycleWhile in interface ReactiveSeq<T>cycleWhile in interface Traversable<T>predicate - repeat while truepublic final ReactiveSeq<T> cycleUntil(java.util.function.Predicate<? super T> predicate)
ReactiveSeq
MutableInt count =MutableInt.of(0);
ReactiveSeq.of(1,2,2)
.cycleUntil(next -> count.get()>6)
.peek(i-> count.mutate(i->i+1))
.collect(Collectors.toList());
//List[1,2,2,1,2,2,1]
cycleUntil in interface ReactiveSeq<T>cycleUntil in interface Traversable<T>predicate - repeat while truepublic final <S> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,S>> zip(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"]]
zip in interface ReactiveSeq<T>zip in interface Traversable<T>zip in interface Zippable<T>zip in interface org.jooq.lambda.Seq<T>second - Stream to combine withpublic final <S,U> ReactiveSeq<org.jooq.lambda.tuple.Tuple3<T,S,U>> zip3(java.util.stream.Stream<? extends S> second, java.util.stream.Stream<? 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(Collectors.toList());
// [[1,100,'a'],[2,200,'b'],[3,300,'c']]
zip3 in interface ReactiveSeq<T>zip3 in interface Traversable<T>public final <T2,T3,T4> ReactiveSeq<org.jooq.lambda.tuple.Tuple4<T,T2,T3,T4>> zip4(java.util.stream.Stream<? extends T2> second, java.util.stream.Stream<? extends T3> third, java.util.stream.Stream<? 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(Collectors.toList());
// [[1,100,'a',"hello"],[2,200,'b',"world"]]
zip4 in interface ReactiveSeq<T>zip4 in interface Traversable<T>public final <S,R> ReactiveSeq<R> zipStream(java.util.stream.BaseStream<? extends S,? extends java.util.stream.BaseStream<? extends S,?>> second, java.util.function.BiFunction<? super T,? super S,? extends R> zipper)
ReactiveSeq
Stream<List<Integer>> zipped = ReactiveSeq.of(1, 2, 3)).zipStream(Stream.of(2, 3, 4), (a, b) -> Arrays.asList(a, b));
// [[1,2][2,3][3,4]]
zipStream in interface ReactiveSeq<T>second - Stream to zip withzipper - Zip funcitonpublic final ReactiveSeq<ListX<T>> sliding(int windowSize)
ReactiveSeq
List<List<Integer>> list = ReactiveSeq.of(1, 2, 3, 4, 5, 6).sliding(2).collect(Collectors.toList());
assertThat(list.get(0), hasItems(1, 2));
assertThat(list.get(1), hasItems(2, 3));
sliding in interface ReactiveSeq<T>sliding in interface Traversable<T>windowSize - Size of sliding windowpublic final ReactiveSeq<ListX<T>> sliding(int windowSize, int increment)
ReactiveSeq
List<List<Integer>> list = ReactiveSeq.of(1, 2, 3, 4, 5, 6).sliding(3, 2).collect(Collectors.toList());
assertThat(list.get(0), hasItems(1, 2, 3));
assertThat(list.get(1), hasItems(3, 4, 5));
sliding in interface ReactiveSeq<T>sliding in interface Traversable<T>windowSize - number of elements in each batchincrement - for each windowpublic final ReactiveSeq<ListX<T>> grouped(int groupSize)
ReactiveSeq
List<List<Integer>> list = ReactiveSeq.of(1, 2, 3, 4, 5, 6).grouped(3).collect(Collectors.toList());
assertThat(list.get(0), hasItems(1, 2, 3));
assertThat(list.get(1), hasItems(4, 5, 6));
grouped in interface ReactiveSeq<T>grouped in interface Traversable<T>groupSize - Size of each Grouppublic 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
groupedStatefullyUntil in interface ReactiveSeq<T>groupedStatefullyUntil in interface Traversable<T>predicate - Window while truepublic final <K> MapX<K,java.util.List<T>> groupBy(java.util.function.Function<? super T,? extends K> classifier)
ReactiveSeq
Map<Integer, List<Integer>> map1 = of(1, 2, 3, 4).groupBy(i -> i % 2);
assertEquals(asList(2, 4), map1.get(0));
assertEquals(asList(1, 3), map1.get(1));
assertEquals(2, map1.size());
public final ReactiveSeq<T> distinct()
distinct in interface ReactiveSeq<T>distinct in interface Traversable<T>distinct in interface java.util.stream.Stream<T>distinct in interface org.jooq.lambda.Seq<T>public final ReactiveSeq<T> scanLeft(Monoid<T> monoid)
ReactiveSeq
assertEquals(asList("", "a", "ab", "abc"),ReactiveSeq.of("a", "b", "c")
.scanLeft(Reducers.toString("")).toList());
scanLeft in interface ReactiveSeq<T>scanLeft in interface Traversable<T>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));
scanLeft in interface ReactiveSeq<T>scanLeft in interface Traversable<T>scanLeft in interface org.jooq.lambda.Seq<T>public final ReactiveSeq<T> scanRight(Monoid<T> monoid)
ReactiveSeq
assertThat(of("a", "b", "c").scanRight(Monoid.of("", String::concat)).toList().size(),
is(asList("", "c", "bc", "abc").size()));
scanRight in interface ReactiveSeq<T>scanRight in interface Traversable<T>public final <U> ReactiveSeq<U> scanRight(U identity, java.util.function.BiFunction<? super T,? super U,? extends U> combiner)
ReactiveSeq
assertThat(of("a", "ab", "abc").map(str->str.length()).scanRight(0, (t, u) -> u + t).toList().size(),
is(asList(0, 3, 5, 6).size()));
scanRight in interface ReactiveSeq<T>scanRight in interface Traversable<T>scanRight in interface org.jooq.lambda.Seq<T>public final ReactiveSeq<T> sorted()
ReactiveSeq
assertThat(ReactiveSeq.of(4,3,6,7)).sorted().toList(),equalTo(Arrays.asList(3,4,6,7)));
sorted in interface ReactiveSeq<T>sorted in interface Traversable<T>sorted in interface java.util.stream.Stream<T>sorted in interface org.jooq.lambda.Seq<T>public final ReactiveSeq<T> sorted(java.util.Comparator<? super T> c)
ReactiveSeq
assertThat(ReactiveSeq.of(4,3,6,7).sorted((a,b) -> b-a).toList(),equalTo(Arrays.asList(7,6,4,3)));
sorted in interface ReactiveSeq<T>sorted in interface Traversable<T>sorted in interface java.util.stream.Stream<T>sorted in interface org.jooq.lambda.Seq<T>c - Compartor to sort withpublic final ReactiveSeq<T> skip(long num)
ReactiveSeq
assertThat(ReactiveSeq.of(4,3,6,7).skip(2).toList(),equalTo(Arrays.asList(6,7)));
skip in interface ReactiveSeq<T>skip in interface Traversable<T>skip in interface java.util.stream.Stream<T>skip in interface org.jooq.lambda.Seq<T>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)));
skipWhile in interface ReactiveSeq<T>skipWhile in interface Traversable<T>skipWhile in interface org.jooq.lambda.Seq<T>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)));
skipUntil in interface ReactiveSeq<T>skipUntil in interface Traversable<T>skipUntil in interface org.jooq.lambda.Seq<T>p - Predicate to skip until truepublic final ReactiveSeq<T> limit(long num)
ReactiveSeq
assertThat(ReactiveSeq.of(4,3,6,7).limit(2).toList(),equalTo(Arrays.asList(4,3));
limit in interface ReactiveSeq<T>limit in interface Traversable<T>limit in interface java.util.stream.Stream<T>limit in interface org.jooq.lambda.Seq<T>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)));
limitWhile in interface ReactiveSeq<T>limitWhile in interface Traversable<T>limitWhile in interface org.jooq.lambda.Seq<T>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)));
limitUntil in interface ReactiveSeq<T>limitUntil in interface Traversable<T>limitUntil in interface org.jooq.lambda.Seq<T>p - Limit until predicate is truepublic final ReactiveSeq<T> parallel()
public 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 ReactiveSeq<T>allMatch in interface CyclopsCollectable<T>allMatch in interface java.util.stream.Stream<T>allMatch in interface org.jooq.lambda.Collectable<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 ReactiveSeq<T>anyMatch in interface CyclopsCollectable<T>anyMatch in interface java.util.stream.Stream<T>anyMatch in interface org.jooq.lambda.Collectable<T>c - Predicate to check if any matchpublic boolean xMatch(int num,
java.util.function.Predicate<? super T> c)
ReactiveSeq
assertTrue(ReactiveSeq.of(1,2,3,5,6,7).xMatch(3, i-> i>4 ));
public final boolean noneMatch(java.util.function.Predicate<? super T> c)
noneMatch in interface ReactiveSeq<T>noneMatch in interface CyclopsCollectable<T>noneMatch in interface java.util.stream.Stream<T>noneMatch in interface org.jooq.lambda.Collectable<T>public final java.lang.String join()
ReactiveSeq
assertEquals("123".length(),ReactiveSeq.of(1, 2, 3).join().length());
public final java.lang.String join(java.lang.String sep)
ReactiveSeq
assertEquals("1, 2, 3".length(), ReactiveSeq.of(1, 2, 3).join(", ").length());
public final java.lang.String join(java.lang.String sep,
java.lang.String start,
java.lang.String end)
ReactiveSeq
assertEquals("^1|2|3$".length(), of(1, 2, 3).join("|", "^", "$").length());
public final <U extends java.lang.Comparable<? super U>> java.util.Optional<T> minBy(java.util.function.Function<? super T,? extends U> function)
minBy in interface ReactiveSeq<T>minBy in interface CyclopsCollectable<T>minBy in interface org.jooq.lambda.Collectable<T>public final java.util.Optional<T> min(java.util.Comparator<? super T> comparator)
min in interface ReactiveSeq<T>min in interface CyclopsCollectable<T>min in interface java.util.stream.Stream<T>min in interface org.jooq.lambda.Collectable<T>public final <C extends java.lang.Comparable<? super C>> java.util.Optional<T> maxBy(java.util.function.Function<? super T,? extends C> f)
maxBy in interface ReactiveSeq<T>maxBy in interface CyclopsCollectable<T>maxBy in interface org.jooq.lambda.Collectable<T>public final java.util.Optional<T> max(java.util.Comparator<? super T> comparator)
max in interface ReactiveSeq<T>max in interface CyclopsCollectable<T>max in interface java.util.stream.Stream<T>max in interface org.jooq.lambda.Collectable<T>public final HeadAndTail<T> headAndTail()
IterableFoldable
ReactiveSeq<String> helloWorld = ReactiveSeq.Of("hello","world","last");
HeadAndTail<String> headAndTail = helloWorld.headAndTail();
String head = headAndTail.head();
//head == "hello"
ReactiveSeq<String> tail = headAndTail.tail();
//["world","last]
headAndTail in interface ReactiveSeq<T>headAndTail in interface IterableFoldable<T>public final java.util.Optional<T> findFirst()
findFirst in interface ReactiveSeq<T>findFirst in interface Foldable<T>findFirst in interface java.util.stream.Stream<T>
ReactiveSeq.of(1,2,3,4,5).filter(it -> it <3).findFirst().get();
//3
(deterministic)public final java.util.Optional<T> findAny()
findAny in interface ReactiveSeq<T>findAny in interface Foldable<T>findAny in interface java.util.stream.Stream<T>
ReactiveSeq.of(1,2,3,4,5).filter(it -> it <3).findAny().get();
//3
(non-deterministic)public final <R> R mapReduce(Reducer<R> reducer)
ReactiveSeq
ReactiveSeq.of("hello","2","world","4").mapReduce(Reducers.toCountInt());
//4
public final <R> R mapReduce(java.util.function.Function<? super T,? extends R> mapper, Monoid<R> reducer)
ReactiveSeq
ReactiveSeq.of("one","two","three","four")
.mapReduce(this::toInt,Reducers.toTotalInt());
//10
int toInt(String s){
if("one".equals(s))
return 1;
if("two".equals(s))
return 2;
if("three".equals(s))
return 3;
if("four".equals(s))
return 4;
return -1;
}
public final <R,A> R collect(java.util.stream.Collector<? super T,A,R> collector)
collect in interface ReactiveSeq<T>collect in interface CyclopsCollectable<T>collect in interface java.util.stream.Stream<T>collect in interface org.jooq.lambda.Collectable<T>public final <R> R collect(java.util.function.Supplier<R> supplier,
java.util.function.BiConsumer<R,? super T> accumulator,
java.util.function.BiConsumer<R,R> combiner)
collect in interface java.util.stream.Stream<T>public final T reduce(Monoid<T> reducer)
ReactiveSeq
ReactiveSeq.of("hello","2","world","4").reduce(Reducers.toString(","));
//hello,2,world,4
public final java.util.Optional<T> reduce(java.util.function.BinaryOperator<T> accumulator)
FoldableStream.reduce(BinaryOperator)
ReactiveSeq.of(1,2,3,4,5).map(it -> it*100).reduce(
(acc,next) -> acc+next)
//Optional[1500]
public final T reduce(T identity, java.util.function.BinaryOperator<T> accumulator)
FoldableStream.reduce(Object, BinaryOperator)reduce in interface ReactiveSeq<T>reduce in interface Foldable<T>reduce in interface java.util.stream.Stream<T>accumulator - Combiner functionpublic final <U> U reduce(U identity,
java.util.function.BiFunction<U,? super T,U> accumulator,
java.util.function.BinaryOperator<U> combiner)
FoldableStream.reduce(Object, BiFunction, BinaryOperator)public final ListX<T> reduce(java.util.stream.Stream<? extends Monoid<T>> reducers)
ReactiveSeq
Monoid<Integer> sum = Monoid.of(0, (a, b) -> a + b);
Monoid<Integer> mult = Monoid.of(1, (a, b) -> a * b);
List<Integer> result = ReactiveSeq.of(1, 2, 3, 4).reduce(Arrays.asList(sum, mult).stream());
assertThat(result, equalTo(Arrays.asList(10, 24)));
public final ListX<T> reduce(java.lang.Iterable<? extends Monoid<T>> reducers)
ReactiveSeq
Monoid<Integer> sum = Monoid.of(0,(a,b)->a+b);
Monoid<Integer> mult = Monoid.of(1,(a,b)->a*b);
List<Integer> result = ReactiveSeq.of(1,2,3,4))
.reduce(Arrays.asList(sum,mult) );
assertThat(result,equalTo(Arrays.asList(10,24)));
public final <T> T foldLeftMapToType(Reducer<T> reducer)
public final T foldRight(Monoid<T> reducer)
ReactiveSeq
ReactiveSeq.of("a","b","c").foldRight(Reducers.toString(""));
// "cab"
public final <U> U foldRight(U seed,
java.util.function.BiFunction<? super T,? super U,? extends U> function)
FoldablefoldRight in interface ReactiveSeq<T>foldRight in interface Foldable<T>foldRight in interface org.jooq.lambda.Seq<T>seed - Identity value for the combiner function (leaves the input unchanged)function - Combining functionpublic final <T> T foldRightMapToType(Reducer<T> reducer)
ReactiveSeq
ReactiveSeq.of(1,2,3).foldRightMapToType(Reducers.toString(""));
// "321"
foldRightMapToType in interface ReactiveSeq<T>foldRightMapToType in interface Foldable<T>reducer - Monoid to reduce valuespublic final Streamable<T> toStreamable()
ReactiveSeq
Streamable<Integer> repeat = ReactiveSeq.of(1,2,3,4,5,6)
.map(i->i*2)
.toStreamable();
repeat.stream().toList(); //Arrays.asList(2,4,6,8,10,12));
repeat.stream().toList() //Arrays.asList(2,4,6,8,10,12));
toStreamable in interface ReactiveSeq<T>toStreamable in interface ConvertableSequence<T>public final java.util.Set<T> toSet()
toSet in interface ReactiveSeq<T>toSet in interface CyclopsCollectable<T>toSet in interface org.jooq.lambda.Collectable<T>public final java.util.List<T> toList()
toList in interface ReactiveSeq<T>toList in interface CyclopsCollectable<T>toList in interface org.jooq.lambda.Collectable<T>public final <C extends java.util.Collection<T>> C toCollection(java.util.function.Supplier<C> collectionFactory)
toCollection in interface ReactiveSeq<T>toCollection in interface CyclopsCollectable<T>toCollection in interface org.jooq.lambda.Collectable<T>public final <T> java.util.stream.Stream<T> toStream()
ReactiveSeqtoStream in interface ReactiveSeq<T>public final ReactiveSeq<T> stream()
ReactiveSeqstream in interface ReactiveSeq<T>stream in interface ExtendedTraversable<T>stream in interface Foldable<T>stream in interface IterableFunctor<T>stream in interface ConvertableSequence<T>stream in interface TransformerTraversable<T>stream in interface Traversable<T>stream in interface org.jooq.lambda.Seq<T>public final boolean startsWithIterable(java.lang.Iterable<T> iterable)
ReactiveSeq
assertTrue(ReactiveSeq.of(1,2,3,4).startsWith(Arrays.asList(1,2,3)));
startsWithIterable in interface ReactiveSeq<T>startsWithIterable in interface Foldable<T>public final boolean startsWith(java.util.stream.Stream<T> stream2)
ReactiveSeq
assertTrue(ReactiveSeq.of(1,2,3,4).startsWith(Stream.of(1,2,3)))
startsWith in interface ReactiveSeq<T>startsWith in interface Foldable<T>stream2 - Stream to check if this Foldable has the same elements in the same order, at the startpublic AnyMSeq<T> anyM()
anyM in interface ReactiveSeq<T>public final <R> ReactiveSeq<R> map(java.util.function.Function<? super T,? extends R> fn)
Functor
of(1,2,3).map(i->i*2)
//[2,4,6]
map in interface ReactiveSeq<T>map in interface FilterableFunctor<T>map in interface Functor<T>map in interface IterableFunctor<T>map in interface java.util.stream.Stream<T>map in interface org.jooq.lambda.Seq<T>fn - Transformation functionpublic final ReactiveSeq<T> peek(java.util.function.Consumer<? super T> c)
Functor
of(1,2,3).map(System.out::println)
1
2
3
peek in interface ReactiveSeq<T>peek in interface Functor<T>peek in interface java.util.stream.Stream<T>peek in interface org.jooq.lambda.Seq<T>c - Consumer that recieves each element from this Functorpublic 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).stream())
.toList(),equalTo(asList(1, -1, 2, -2)));
flatMap in interface ReactiveSeq<T>flatMap in interface java.util.stream.Stream<T>flatMap in interface org.jooq.lambda.Seq<T>fn - to be appliedpublic final <R> ReactiveSeq<R> flatMapAnyM(java.util.function.Function<? super T,AnyM<? extends R>> fn)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3)).flatMapAnyM(i-> anyM(CompletableFuture.completedFuture(i+2))).toList(),equalTo(Arrays.asList(3,4,5)));
flatMapAnyM in interface ReactiveSeq<T>fn - to be appliedpublic final <R> ReactiveSeq<R> flatMapIterable(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
flatMapIterable in interface ReactiveSeq<T>public final <R> ReactiveSeq<R> flatMapStream(java.util.function.Function<? super T,java.util.stream.BaseStream<? extends R,?>> fn)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3)
.flatMapStream(i->IntStream.of(i))
.toList(),equalTo(Arrays.asList(1,2,3)));
flatMapStream in interface ReactiveSeq<T>fn - to be appliedpublic final <R> ReactiveSeq<R> flatMapOptional(java.util.function.Function<? super T,java.util.Optional<? extends R>> fn)
public final <R> ReactiveSeq<R> flatMapCompletableFuture(java.util.function.Function<? super T,java.util.concurrent.CompletableFuture<? extends R>> fn)
public final ReactiveSeq<java.lang.Character> flatMapCharSequence(java.util.function.Function<? super T,java.lang.CharSequence> fn)
public final ReactiveSeq<java.lang.String> flatMapFile(java.util.function.Function<? super T,java.io.File> fn)
public final ReactiveSeq<java.lang.String> flatMapURL(java.util.function.Function<? super T,java.net.URL> fn)
public final ReactiveSeq<java.lang.String> flatMapBufferedReader(java.util.function.Function<? super T,java.io.BufferedReader> fn)
public final ReactiveSeq<T> filter(java.util.function.Predicate<? super T> fn)
Filterable
of(1,2,3).filter(i->i>2);
//[3]
filter in interface ReactiveSeq<T>filter in interface Filterable<T>filter in interface FilterableFunctor<T>filter in interface JoolManipulation<T>filter in interface java.util.stream.Stream<T>filter in interface org.jooq.lambda.Seq<T>fn - to filter elements by, retaining matchespublic void forEach(java.util.function.Consumer<? super T> action)
public java.util.Iterator<T> iterator()
public java.util.Spliterator<T> spliterator()
public boolean isParallel()
public ReactiveSeq<T> sequential()
sequential in interface ReactiveSeq<T>sequential in interface java.util.stream.BaseStream<T,java.util.stream.Stream<T>>sequential in interface org.jooq.lambda.Seq<T>public ReactiveSeq<T> unordered()
public java.util.stream.IntStream mapToInt(java.util.function.ToIntFunction<? super T> mapper)
public java.util.stream.LongStream mapToLong(java.util.function.ToLongFunction<? super T> mapper)
public java.util.stream.DoubleStream mapToDouble(java.util.function.ToDoubleFunction<? super T> mapper)
public java.util.stream.IntStream flatMapToInt(java.util.function.Function<? super T,? extends java.util.stream.IntStream> mapper)
public java.util.stream.LongStream flatMapToLong(java.util.function.Function<? super T,? extends java.util.stream.LongStream> mapper)
public java.util.stream.DoubleStream flatMapToDouble(java.util.function.Function<? super T,? extends java.util.stream.DoubleStream> mapper)
public void forEachOrdered(java.util.function.Consumer<? super T> action)
forEachOrdered in interface java.util.stream.Stream<T>public java.lang.Object[] toArray()
toArray in interface java.util.stream.Stream<T>public <A> A[] toArray(java.util.function.IntFunction<A[]> generator)
toArray in interface java.util.stream.Stream<T>public long count()
count in interface ReactiveSeq<T>count in interface CyclopsCollectable<T>count in interface java.util.stream.Stream<T>count in interface org.jooq.lambda.Collectable<T>count in interface org.jooq.lambda.Seq<T>public ReactiveSeq<T> intersperse(T value)
ReactiveSeqintersperse in interface ReactiveSeq<T>intersperse in interface Traversable<T>intersperse in interface org.jooq.lambda.Seq<T>public <U> ReactiveSeq<U> ofType(java.lang.Class<? extends U> type)
ReactiveSeqofType in interface ReactiveSeq<T>ofType in interface Filterable<T>ofType in interface JoolManipulation<T>ofType in interface org.jooq.lambda.Seq<T>public <U> ReactiveSeq<U> cast(java.lang.Class<? extends U> type)
ReactiveSeqClassCastException.
// ClassCastException ReactiveSeq.of(1, "a", 2, "b", 3).cast(Integer.class)public CollectionX<T> toLazyCollection()
ReactiveSeq
Collection<Integer> col = ReactiveSeq.of(1, 2, 3, 4, 5)
.peek(System.out::println)
.toLazyCollection();
col.forEach(System.out::println);
// Will print out "first!" before anything else
toLazyCollection in interface ReactiveSeq<T>toLazyCollection in interface Foldable<T>public CollectionX<T> toConcurrentLazyCollection()
ReactiveSeq
Collection<Integer> col = ReactiveSeq.of(1, 2, 3, 4, 5).peek(System.out::println).toConcurrentLazyCollection();
col.forEach(System.out::println);
// Will print out "first!" before anything else
toConcurrentLazyCollection in interface ReactiveSeq<T>toConcurrentLazyCollection in interface Foldable<T>public Streamable<T> toLazyStreamable()
public Streamable<T> toConcurrentLazyStreamable()
ReactiveSeq
Streamable<Integer> repeat = ReactiveSeq.of(1, 2, 3, 4, 5, 6).map(i -> i + 2).toConcurrentLazyStreamable();
assertThat(repeat.stream().toList(), equalTo(Arrays.asList(2, 4, 6, 8, 10, 12)));
assertThat(repeat.stream().toList(), equalTo(Arrays.asList(2, 4, 6, 8, 10, 12)));
toConcurrentLazyStreamable in interface ReactiveSeq<T>toConcurrentLazyStreamable in interface Foldable<T>public ReactiveSeq<T> reverse()
Traversable assertThat( of(1, 2, 3).reverse().toList(),
equalTo(asList(3, 2, 1))); reverse in interface ReactiveSeq<T>reverse in interface Traversable<T>reverse in interface org.jooq.lambda.Seq<T>public ReactiveSeq<T> onClose(java.lang.Runnable closeHandler)
public void close()
public ReactiveSeq<T> shuffle()
shuffle in interface ReactiveSeq<T>shuffle in interface Traversable<T>shuffle in interface org.jooq.lambda.Seq<T>public ReactiveSeq<T> appendStream(java.util.stream.Stream<T> stream)
ReactiveSeq
List<String> result = ReactiveSeq.of(1, 2, 3).appendStream(ReactiveSeq.of(100, 200, 300)).map(it -> it + "!!").collect(Collectors.toList());
assertThat(result, equalTo(Arrays.asList("1!!", "2!!", "3!!", "100!!", "200!!", "300!!"))); *
appendStream in interface ReactiveSeq<T>stream - to appendpublic ReactiveSeq<T> prependStream(java.util.stream.Stream<T> stream)
ReactiveSeq
List<String> result = ReactiveSeq.of(1, 2, 3)
.prependStream(of(100, 200, 300))
.map(it -> it + "!!")
.collect(Collectors.toList());
assertThat(result, equalTo(Arrays.asList("100!!", "200!!", "300!!", "1!!", "2!!", "3!!")));
prependStream in interface ReactiveSeq<T>stream - to Prependpublic ReactiveSeq<T> append(T... values)
ReactiveSeq
List<String> result = ReactiveSeq.of(1, 2, 3).append(100, 200, 300).map(it -> it + "!!").collect(Collectors.toList());
assertThat(result, equalTo(Arrays.asList("1!!", "2!!", "3!!", "100!!", "200!!", "300!!"))); *
append in interface ReactiveSeq<T>append in interface org.jooq.lambda.Seq<T>values - to appendpublic ReactiveSeq<T> prepend(T... values)
ReactiveSeq
List<String> result = ReactiveSeq.of(1,2,3)
.prepend(100,200,300)
.map(it ->it+"!!")
.collect(Collectors.toList());
assertThat(result,equalTo(Arrays.asList("100!!","200!!","300!!","1!!","2!!","3!!")));
prepend in interface ReactiveSeq<T>prepend in interface org.jooq.lambda.Seq<T>values - to prependpublic ReactiveSeq<T> insertAt(int pos, T... values)
ReactiveSeq
List<String> result = ReactiveSeq.of(1, 2, 3).insertAt(1, 100, 200, 300).map(it -> it + "!!").collect(Collectors.toList());
assertThat(result, equalTo(Arrays.asList("1!!", "100!!", "200!!", "300!!", "2!!", "3!!"))); *
insertAt in interface ReactiveSeq<T>pos - to insert data atvalues - to insertpublic ReactiveSeq<T> deleteBetween(int start, int end)
ReactiveSeq
List<String> result = ReactiveSeq.of(1, 2, 3, 4, 5, 6).deleteBetween(2, 4).map(it -> it + "!!").collect(Collectors.toList());
assertThat(result, equalTo(Arrays.asList("1!!", "2!!", "5!!", "6!!"))); *
deleteBetween in interface ReactiveSeq<T>start - indexend - indexpublic ReactiveSeq<T> insertStreamAt(int pos, java.util.stream.Stream<T> stream)
ReactiveSeq
List<String> result = ReactiveSeq.of(1, 2, 3).insertStreamAt(1, of(100, 200, 300)).map(it -> it + "!!").collect(Collectors.toList());
assertThat(result, equalTo(Arrays.asList("1!!", "100!!", "200!!", "300!!", "2!!", "3!!")));
insertStreamAt in interface ReactiveSeq<T>pos - to insert Stream atstream - to insertpublic FutureOperations<T> futureOperations(java.util.concurrent.Executor exec)
ReactiveSeqfutureOperations in interface ReactiveSeq<T>futureOperations in interface Traversable<T>exec - Executor to use for Stream executionpublic boolean endsWithIterable(java.lang.Iterable<T> iterable)
ReactiveSeq
assertTrue(ReactiveSeq.of(1,2,3,4,5,6)
.endsWith(Arrays.asList(5,6)));
endsWithIterable in interface ReactiveSeq<T>endsWithIterable in interface Foldable<T>iterable - Values to checkpublic HotStream<T> hotStream(java.util.concurrent.Executor e)
ReactiveSeqReactiveSeq.primedHotStream(Executor).
The generated HotStream is not pausable, for a pausable HotStream @see ReactiveSeq.pausableHotStream(Executor).
Turns this ReactiveSeq into a HotStream, a connectable Stream, being
executed on a thread on the supplied executor, that is producing data
HotStream<Integer> ints = ReactiveSeq.range(0,Integer.MAX_VALUE)
.hotStream(exec)
ints.connect().forEach(System.out::println);
//print out all the ints
//multiple consumers are possible, so other Streams can connect on different Threads
hotStream in interface ReactiveSeq<T>e - Executor to execute this ReactiveSeq onpublic T firstValue()
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3,4)
.map(u->{throw new RuntimeException();})
.recover(e->"hello")
.firstValue(),equalTo("hello"));
firstValue in interface ReactiveSeq<T>firstValue in interface Foldable<T>public void subscribe(org.reactivestreams.Subscriber<? super T> sub)
subscribe in interface Traversable<T>subscribe in interface org.reactivestreams.Publisher<T>public <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> zip(org.jooq.lambda.Seq<? extends U> other)
ReactiveSeq
List<Tuple2<Integer, String>> list = of(1, 2).zip(of("a", "b", "c", "d")).toList();
// [[1,"a"],[2,"b"]]
zip in interface ReactiveSeq<T>zip in interface Traversable<T>zip in interface Zippable<T>zip in interface org.jooq.lambda.Seq<T>other - Seq to combine withpublic ReactiveSeq<T> onEmpty(T value)
OnEmptyonEmpty in interface ReactiveSeq<T>onEmpty in interface OnEmpty<T>onEmpty in interface Traversable<T>onEmpty in interface org.jooq.lambda.Seq<T>public ReactiveSeq<T> onEmptyGet(java.util.function.Supplier<? extends T> supplier)
OnEmptyonEmptyGet in interface ReactiveSeq<T>onEmptyGet in interface OnEmpty<T>onEmptyGet in interface Traversable<T>onEmptyGet in interface org.jooq.lambda.Seq<T>supplier - to determine new value for containerpublic <X extends java.lang.Throwable> ReactiveSeq<T> onEmptyThrow(java.util.function.Supplier<? extends X> supplier)
OnEmptyonEmptyThrow in interface ReactiveSeq<T>onEmptyThrow in interface OnEmpty<T>onEmptyThrow in interface Traversable<T>onEmptyThrow in interface org.jooq.lambda.Seq<T>supplier - to create exception frompublic ReactiveSeq<T> concat(java.util.stream.Stream<? extends T> other)
concat in interface ReactiveSeq<T>concat in interface org.jooq.lambda.Seq<T>public ReactiveSeq<T> concat(T other)
concat in interface ReactiveSeq<T>concat in interface org.jooq.lambda.Seq<T>public ReactiveSeq<T> concat(T... other)
concat in interface ReactiveSeq<T>concat in interface org.jooq.lambda.Seq<T>public <U> ReactiveSeq<T> distinct(java.util.function.Function<? super T,? extends U> keyExtractor)
distinct in interface ReactiveSeq<T>distinct in interface org.jooq.lambda.Seq<T>public <U,R> ReactiveSeq<R> zip(org.jooq.lambda.Seq<? extends U> other, java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
Zippablezip in interface ReactiveSeq<T>zip in interface Traversable<T>zip in interface Zippable<T>zip in interface org.jooq.lambda.Seq<T>other - Seq to combine withzipper - Zip / combining functionpublic ReactiveSeq<T> shuffle(java.util.Random random)
shuffle in interface ReactiveSeq<T>shuffle in interface Traversable<T>shuffle in interface org.jooq.lambda.Seq<T>public ReactiveSeq<T> slice(long from, long to)
slice in interface ReactiveSeq<T>slice in interface Traversable<T>slice in interface org.jooq.lambda.Seq<T>public <U extends java.lang.Comparable<? super U>> ReactiveSeq<T> sorted(java.util.function.Function<? super T,? extends U> function)
sorted in interface ReactiveSeq<T>sorted in interface Traversable<T>sorted in interface org.jooq.lambda.Seq<T>public ReactiveSeq<T> xPer(int x, long time, java.util.concurrent.TimeUnit t)
ReactiveSeq
code
SimpleTimer timer = new SimpleTimer();
ReactiveSeq.of(1, 2, 3, 4, 5, 6)
.xPer(6, 100000000, TimeUnit.NANOSECONDS)
.collect(Collectors.toList())
.size();
//6
xPer in interface ReactiveSeq<T>x - number of elements to emittime - periodt - Time unitpublic ReactiveSeq<T> onePer(long time, java.util.concurrent.TimeUnit t)
ReactiveSeq
ReactiveSeq.iterate("", last -> "next")
.limit(100)
.batchBySize(10)
.onePer(1, TimeUnit.MICROSECONDS)
.peek(batch -> System.out.println("batched : " + batch))
.flatMap(Collection::stream)
.peek(individual -> System.out.println("Flattened : "
+ individual))
.forEach(a->{});
onePer in interface ReactiveSeq<T>time - periodt - Time unitpublic ReactiveSeq<T> debounce(long time, java.util.concurrent.TimeUnit t)
ReactiveSeq
ReactiveSeq.of(1,2,3,4,5,6)
.debounce(1000,TimeUnit.SECONDS).toList();
// 1
debounce in interface ReactiveSeq<T>time - Time to apply debouncing overt - Time unit for debounce periodpublic 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]]
groupedBySizeAndTime in interface ReactiveSeq<T>size - Max size of a batchtime - (Max) time period to build a single 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(Collectors.toList()).size(),is(1));
assertThat(ReactiveSeq.of(1,2,3,4,5,6).batchByTime(1,TimeUnit.NANOSECONDS).collect(Collectors.toList()).size(),greaterThan(5));
groupedByTime in interface ReactiveSeq<T>time - - time period to build a single batch int - time unit for batchpublic T foldRight(T identity, java.util.function.BinaryOperator<T> accumulator)
ReactiveSeq
assertTrue(ReactiveSeq.of("a","b","c").foldRight("", String::concat).equals("cba"));
public boolean endsWith(java.util.stream.Stream<T> iterable)
ReactiveSeq
assertTrue(ReactiveSeq.of(1,2,3,4,5,6)
.endsWith(Stream.of(5,6)));
public 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]
skip in interface ReactiveSeq<T>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]
limit in interface ReactiveSeq<T>time - Length of timeunit - Time unitpublic ReactiveSeq<T> fixedDelay(long l, java.util.concurrent.TimeUnit unit)
ReactiveSeq
SimpleTimer timer = new SimpleTimer();
ReactiveSeq.of(1, 2, 3, 4, 5, 6)
.fixedDelay(10000, TimeUnit.NANOSECONDS)
.collect(Collectors.toList())
.size();
//6
assertThat(timer.getElapsedNanoseconds(), greaterThan(60000l));
fixedDelay in interface ReactiveSeq<T>l - time length in nanos of the delayunit - for the delaypublic ReactiveSeq<T> jitter(long l)
ReactiveSeq
{ @code
SimpleTimer timer = new SimpleTimer();
ReactiveSeq.of(1, 2, 3, 4, 5, 6)
.jitter(10000)
.collect(Collectors.toList());
assertThat(timer.getElapsedNanoseconds(), greaterThan(20000l));
}
jitter in interface ReactiveSeq<T>l - - random number less than this is used for each jitterpublic 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));
groupedUntil in interface ReactiveSeq<T>groupedUntil in interface Traversable<T>predicate - Batch until predicate holds, then 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));
groupedWhile in interface ReactiveSeq<T>groupedWhile in interface Traversable<T>predicate - Batch while predicate holds, then 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));
groupedWhile in interface ReactiveSeq<T>groupedWhile in interface Traversable<T>predicate - Batch while predicate holds, then 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));
groupedUntil in interface ReactiveSeq<T>groupedUntil in interface Traversable<T>predicate - Batch until predicate holds, then 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]]
groupedBySizeAndTime in interface ReactiveSeq<T>size - Max size of a batchtime - (Max) time period to build a single batch inunit - time unit for batchfactory - Collection factorypublic <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));
groupedByTime in interface ReactiveSeq<T>time - - time period to build a single 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));
grouped in interface ReactiveSeq<T>grouped in interface Traversable<T>size - batch sizefactory - Collection factorypublic ReactiveSeq<T> skipLast(int num)
ReactiveSeqskipLast in interface ReactiveSeq<T>skipLast in interface Traversable<T>public ReactiveSeq<T> limitLast(int num)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3,4,5)
.limitLast(2)
.collect(Collectors.toList()),equalTo(Arrays.asList(4,5)));
limitLast in interface ReactiveSeq<T>limitLast in interface Traversable<T>num - of elements to return (last elements)public ReactiveSeq<T> recover(java.util.function.Function<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"));
recover in interface ReactiveSeq<T>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<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"));
recover in interface ReactiveSeq<T>exceptionClass - Type to recover fromfn - That accepts an error and returns an alternative valuepublic <X extends java.lang.Throwable> org.reactivestreams.Subscription forEachX(long numberOfElements,
java.util.function.Consumer<? super T> consumer)
ReactiveStreamsTerminalOperations
Subscription next = ReactiveSeq.of(1,2,3,4)
.forEachX(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!
forEachX in interface ReactiveStreamsTerminalOperations<T>numberOfElements - To consume from the Stream at this timeconsumer - To accept incoming events from the Streampublic <X extends java.lang.Throwable> org.reactivestreams.Subscription forEachXWithError(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)
.forEachXWithError(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!
forEachXWithError in interface ReactiveStreamsTerminalOperations<T>numberOfElements - To consume from the Stream at this timeconsumer - To accept incoming elements from the StreamconsumerError - To accept incoming processing errors from the Streampublic <X extends java.lang.Throwable> org.reactivestreams.Subscription forEachXEvents(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)
.forEachXEvents(2,System.out::println, e->e.printStackTrace(),()->System.out.println("the end!"));
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 end!
forEachXEvents in interface ReactiveStreamsTerminalOperations<T>numberOfElements - To consume from the Stream at this timeconsumer - To accept incoming elements from the StreamconsumerError - To accept incoming processing errors from the StreamonComplete - To run after an onComplete eventpublic <X extends java.lang.Throwable> void forEachWithError(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)
.forEachWithError(System.out::println, e->e.printStackTrace());
System.out.println("processed!");
//prints
1
2
RuntimeException Stack Trace on System.err
4
processed!
forEachWithError in interface ReactiveStreamsTerminalOperations<T>consumerElement - To accept incoming elements from the StreamconsumerError - To accept incoming processing errors from the Streampublic <X extends java.lang.Throwable> void forEachEvent(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 end!"));
System.out.println("processed!");
//prints
1
2
RuntimeException Stack Trace on System.err
4
processed!
forEachEvent in interface ReactiveStreamsTerminalOperations<T>consumerElement - To accept incoming elements from the StreamconsumerError - To accept incoming processing errors from the StreamonComplete - To run after an onComplete eventpublic HotStream<T> primedHotStream(java.util.concurrent.Executor e)
ReactiveSeqReactiveSeq.hotStream(Executor).
The generated HotStream is not pausable, for a pausable HotStream @see ReactiveSeq.primedPausableHotStream(Executor).
HotStream<Integer> ints = ReactiveSeq.range(0,Integer.MAX_VALUE) .hotStream(exec) ints.connect().forEach(System.out::println); //print out all the ints - starting when connect is called. //multiple consumers are possible, so other Streams can connect on different Threads
primedHotStream in interface ReactiveSeq<T>public PausableHotStream<T> pausableHotStream(java.util.concurrent.Executor e)
ReactiveSeqReactiveSeq.primedPausableHotStream(Executor).
The generated HotStream is pausable, for a unpausable HotStream (slightly faster execution) @see ReactiveSeq.hotStream(Executor).
HotStream<Integer> ints = ReactiveSeq.range(0,Integer.MAX_VALUE)
.hotStream(exec)
ints.connect().forEach(System.out::println);
ints.pause(); //on a separate thread pause the generating Stream
//print out all the ints
//multiple consumers are possible, so other Streams can connect on different Threads
pausableHotStream in interface ReactiveSeq<T>e - Executor to execute this ReactiveSeq onpublic PausableHotStream<T> primedPausableHotStream(java.util.concurrent.Executor e)
ReactiveSeqReactiveSeq.pausableHotStream(Executor).
The generated HotStream is pausable, for a unpausable HotStream @see ReactiveSeq.primedHotStream(Executor).
HotStream<Integer> ints = ReactiveSeq.range(0,Integer.MAX_VALUE) .hotStream(exec) ints.connect().forEach(System.out::println); //print out all the ints - starting when connect is called. //multiple consumers are possible, so other Streams can connect on different Threads
primedPausableHotStream in interface ReactiveSeq<T>public java.lang.String format()
format in interface org.jooq.lambda.Seq<T>public org.jooq.lambda.Collectable<T> collectable()
CyclopsCollectablecollectable in interface ReactiveSeq<T>collectable in interface IterableFunctor<T>collectable in interface CyclopsCollectable<T>public <T> ReactiveSeq<T> unitIterator(java.util.Iterator<T> it)
IterableFunctor
ReactiveSeq<Integer> newSeq = seq.unitIterator(myIterator);
unitIterator in interface ReactiveSeq<T>unitIterator in interface IterableFunctor<T>it - Iterator to create new IterableFunctor frompublic ReactiveSeq<T> append(T value)
append in interface ReactiveSeq<T>append in interface org.jooq.lambda.Seq<T>public ReactiveSeq<T> prepend(T value)
prepend in interface ReactiveSeq<T>prepend in interface org.jooq.lambda.Seq<T>