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 SequenceM
|
ReactiveSeq<T> |
append(T value) |
ReactiveSeq<T> |
appendStream(java.util.stream.Stream<T> stream)
Append Stream to this SequenceM
|
<U> ReactiveSeq<U> |
cast(java.lang.Class<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)
Mutable reduction / collection over this Monad converted to a Stream
|
<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<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
|
<R> ReactiveSeq<R> |
cycle(java.lang.Class<R> monadC,
int times)
Convert to a Stream, repeating the resulting structure specified times
and lifting all values to the specified Monad type
|
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) |
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)
Perform a flatMap operation where the result will be a flattened stream of Strings
from the text loaded from the supplied BufferedReaders
|
ReactiveSeq<java.lang.Character> |
flatMapCharSequence(java.util.function.Function<? super T,java.lang.CharSequence> fn)
Perform a flatMap operation where the result will be a flattened stream of Characters
from the CharSequence returned by the supplied function.
|
<R> ReactiveSeq<R> |
flatMapCompletableFuture(java.util.function.Function<? super T,java.util.concurrent.CompletableFuture<? extends R>> fn)
flatMap to CompletableFuture - will block until Future complete, although (for non-blocking behaviour use AnyM
wrapping CompletableFuture and flatMap to Stream there)
|
ReactiveSeq<java.lang.String> |
flatMapFile(java.util.function.Function<? super T,java.io.File> fn)
Perform a flatMap operation where the result will be a flattened stream of Strings
from the text loaded from the supplied files.
|
<R> ReactiveSeq<R> |
flatMapIterable(java.util.function.Function<? super T,java.lang.Iterable<? extends R>> fn)
Convenience method & performance optimisation
flatMapping to a Stream will result in the Stream being converted to a List, if the host Monad
type is not a Stream.
|
<R> ReactiveSeq<R> |
flatMapOptional(java.util.function.Function<? super T,java.util.Optional<? extends R>> fn)
flatMap to optional - will result in null values being removed
|
<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)
Perform a flatMap operation where the result will be a flattened stream of Strings
from the text loaded from the supplied URLs
|
<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)
foldLeft : immutable reduction from left to right
|
<T> T |
foldLeftMapToType(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
|
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,U,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) |
<R1,R> ReactiveSeq<R> |
forEach2(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1,
java.util.function.Function<? super T,java.util.function.Function<? super R1,? extends R>> yieldingFunction)
Perform a two level nested internal iteration over this Stream and the supplied stream
|
<R1,R> ReactiveSeq<R> |
forEach2(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1,
java.util.function.Function<? super T,java.util.function.Function<? super R1,java.lang.Boolean>> filterFunction,
java.util.function.Function<? super T,java.util.function.Function<? super R1,? extends R>> yieldingFunction)
Perform a two level nested internal iteration over this Stream and the supplied stream
|
<R1,R2,R> ReactiveSeq<R> |
forEach3(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1,
java.util.function.Function<? super T,java.util.function.Function<? super R1,? extends java.util.stream.BaseStream<R2,?>>> stream2,
java.util.function.Function<? super T,java.util.function.Function<? super R1,java.util.function.Function<? super R2,? extends R>>> yieldingFunction)
Perform a three level nested internal iteration over this Stream and the supplied streams
|
<R1,R2,R> ReactiveSeq<R> |
forEach3(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1,
java.util.function.Function<? super T,java.util.function.Function<? super R1,? extends java.util.stream.BaseStream<R2,?>>> stream2,
java.util.function.Function<? super T,java.util.function.Function<? super R1,java.util.function.Function<? super R2,java.lang.Boolean>>> filterFunction,
java.util.function.Function<? super T,java.util.function.Function<? super R1,java.util.function.Function<? super R2,? extends R>>> yieldingFunction)
Perform a three level nested internal iteration over this Stream and the supplied streams
|
<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>> |
groupedStatefullyWhile(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 SequenceM 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 SequenceM 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 SequenceM 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 SequenceM 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
|
HotStream<T> |
hotStream(java.util.concurrent.Executor e)
Turns this SequenceM 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(),of(1, 2, 3).join().length());
|
java.lang.String |
join(java.lang.String sep)
assertEquals("1, 2, 3".length(), 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(anyM(Stream.of(4,3,6,7)).asSequence().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 SequenceM
|
ReactiveSeq<T> |
limitUntil(java.util.function.Predicate<? super T> p)
assertThat(anyM(Stream.of(4,3,6,7)).limitUntil(i->i==6).toList(),equalTo(Arrays.asList(4,3))); |
ReactiveSeq<T> |
limitWhile(java.util.function.Predicate<? super T> p)
assertThat(anyM(Stream.of(4,3,6,7)).asSequence().sorted().limitWhile(i->i<6).toList(),equalTo(Arrays.asList(3,4))); |
<R> ReactiveSeq<R> |
map(java.util.function.Function<? super T,? extends R> fn) |
<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 Monad to the same type as the supplied Monoid (using mapToType on the monoid interface)
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)
Extract the maximum as determined by the supplied function
|
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)
Extract the minimum as determined by supplied function
|
boolean |
noneMatch(java.util.function.Predicate<? super T> c) |
<U> ReactiveSeq<U> |
ofType(java.lang.Class<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) |
ReactiveSeq<T> |
onEmptyGet(java.util.function.Supplier<T> supplier) |
<X extends java.lang.Throwable> |
onEmptyThrow(java.util.function.Supplier<X> 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 SequenceM 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) |
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 SequenceM
|
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) |
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 streamedStreamUtils.sequenceM() 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 streamedStreamUtils.sequenceM() first.
|
T |
reduce(T identity,
java.util.function.BinaryOperator<T> accumulator) |
<U> U |
reduce(U identity,
java.util.function.BiFunction<U,? super T,U> accumulator,
java.util.function.BinaryOperator<U> combiner) |
ReactiveSeq<T> |
reverse() |
ReactiveSeq<T> |
scanLeft(Monoid<T> monoid)
Scan left using supplied Monoid
|
<U> ReactiveSeq<U> |
scanLeft(U seed,
java.util.function.BiFunction<U,? super T,U> function)
Scan left
|
ReactiveSeq<T> |
scanRight(Monoid<T> monoid)
Scan right
|
<U> ReactiveSeq<U> |
scanRight(U identity,
java.util.function.BiFunction<? super T,U,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(anyM(Stream.of(4,3,6,7)).asSequence().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)
assertThat(anyM(Stream.of(4,3,6,7)).asSequence().skipUntil(i->i==6).toList(),equalTo(Arrays.asList(6,7))); |
ReactiveSeq<T> |
skipWhile(java.util.function.Predicate<? super T> p)
assertThat(anyM(Stream.of(4,3,6,7)).asSequence().sorted().skipWhile(i->i<6).toList(),equalTo(Arrays.asList(6,7)));
|
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(anyM(Stream.of(4,3,6,7)).asSequence().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.Iterator<T> iterator)
assertTrue(StreamUtils.sequenceM(Stream.of(1,2,3,4)).startsWith(Arrays.asList(1,2,3).iterator())) |
boolean |
startsWithIterable(java.lang.Iterable<T> iterable)
assertTrue(StreamUtils.sequenceM(Stream.of(1,2,3,4)).startsWith(Arrays.asList(1,2,3)));
|
ReactiveSeq<T> |
stream()
Unwrap this Monad 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 SequenceM into a Collection.
|
Streamable<T> |
toConcurrentLazyStreamable()
{
@code
Streamable<Integer> repeat = ReactiveSeq.of(1, 2, 3, 4, 5, 6).map(i -> i + 2).toConcurrentLazyStreamable();
assertThat(repeat.sequenceM().toList(), equalTo(Arrays.asList(2, 4, 6, 8, 10, 12)));
assertThat(repeat.sequenceM().toList(), equalTo(Arrays.asList(2, 4, 6, 8, 10, 12)));
}
|
CollectionX<T> |
toLazyCollection()
Lazily converts this SequenceM 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 SequenceM into a Stream
|
Streamable<T> |
toStreamable()
Streamable<Integer> repeat = ReactiveSeq.of(1,2,3,4,5,6)
.map(i->i*2)
.toStreamable();
repeat.sequenceM().toList(); //Arrays.asList(2,4,6,8,10,12));
repeat.sequenceM().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) |
ReactiveSeq<T> |
unordered() |
<R> R |
unwrap()
Deprecated.
|
java.util.stream.Stream<T> |
unwrapStream()
Type safe unwrap
|
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<U> other)
Zip 2 streams into one
|
<U,R> ReactiveSeq<R> |
zip(org.jooq.lambda.Seq<U> other,
java.util.function.BiFunction<? super T,? super U,? extends R> zipper) |
<S> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,S>> |
zip(java.util.stream.Stream<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<T2> second,
java.util.stream.Stream<T3> third,
java.util.stream.Stream<T4> fourth)
zip 4 Streams into 1
|
<S,R> ReactiveSeq<R> |
zipAnyM(AnyM<? extends S> second,
java.util.function.BiFunction<? super T,? super S,? extends R> zipper)
Zip this SequenceM against any monad type.
|
<S,R> ReactiveSeq<R> |
zipSequence(ReactiveSeq<? extends S> second,
java.util.function.BiFunction<? super T,? super S,? extends R> zipper)
Generic zip function.
|
<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 Monad with a Stream
|
<U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
zipStream(java.util.stream.Stream<U> other)
Zip 2 streams into one
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
ap1, applicatives, avg, avg, avgDouble, avgInt, avgLong, combinations, combinations, combine, count, countDistinct, countDistinct, countDistinctBy, countDistinctBy, crossJoin, crossJoin, crossJoin, dropRight, dropUntil, dropWhile, elapsed, elementAt, empty, fromDoubleStream, fromIntStream, fromIterable, fromIterator, fromList, fromLongStream, fromStream, generate, get, grouped, grouped, innerJoin, innerJoin, innerJoin, innerJoin, iterate, leftOuterJoin, leftOuterJoin, leftOuterJoin, leftOuterJoin, limitUntilClosed, max, max, max, maxBy, median, median, medianBy, medianBy, min, min, min, minBy, mode, of, onEmptySwitch, patternMatch, percentile, percentile, percentileBy, percentileBy, permutations, print, print, printErr, printOut, range, rangeLong, remove, retry, reversedListOf, reversedOf, rightOuterJoin, rightOuterJoin, rightOuterJoin, single, single, singleOptional, size, skipUntilClosed, subscriber, subStream, sum, sum, sumDouble, sumInt, sumLong, takeRight, takeUntil, takeWhile, timestamp, toList, toMap, toSet, toString, toString, trampoline, unzip, unzip3, unzip4, zip, zipWithIndex
filterNot, notNull, removeAll, removeAll, removeAll, removeAll, retainAll, retainAll, retainAll, retainAll
window, window, window, window, window, window, window, window, window, window, window, window, window, window, window, window, window, window, window, window, window, window, window
append, append, append, cast, concat, concat, concat, concat, concat, contains, containsAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, containsAny, 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, cycle, duplicate, duplicate, findFirst, findSingle, foldLeft, foldLeft, foldLeft, foldLeft, foldRight, foldRight, foldRight, generate, groupBy, groupBy, groupBy, groupBy, groupBy, grouped, grouped, grouped, grouped, grouped, grouped, intersperse, isEmpty, isNotEmpty, join, join, join, join, join, limit, limitUntil, limitUntilClosed, limitWhile, limitWhileClosed, limitWhileClosed, ofType, partition, partition, prepend, prepend, prepend, 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, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, skip, skipUntil, skipUntilClosed, skipWhile, skipWhileClosed, skipWhileClosed, slice, sliding, sorted, splitAt, splitAt, splitAtHead, splitAtHead, toCollection, toList, toMap, toMap, toSet, toString, toString, unfold, 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, zip, zip, zipWithIndex, zipWithIndex, zipWithIndex
ap2, ap3, ap4, ap5
flatMapPublisher, flatMapPublisher, flatMapPublisher, mergePublisher, mergePublisher
lazyOperations, validate, visit, visit
public ReactiveSeqImpl(java.util.stream.Stream<T> stream)
public ReactiveSeqImpl(java.util.stream.Stream<T> stream, ReversableSpliterator rev)
public <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
SequenceeM.generate(()->"next job:"+formatDate(new Date()))
.map(this::processJob)
.schedule("0 20 * * *",Executors.newScheduledThreadPool(1));
Connect to the Scheduled Stream
{ @code HotStream<Data> dataStream = SequenceeM.generate(() -> "next job:" + formatDate(new Date())).map(this::processJob) .schedule("0 20 * * *", Executors.newScheduledThreadPool(1)); data.connect().forEach(this::logToDB); }
schedule
in interface ReactiveSeq<T>
schedule
in interface Traversable<T>
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
SequenceeM.generate(()->"next job:"+formatDate(new Date()))
.map(this::processJob)
.scheduleFixedDelay(60_000,Executors.newScheduledThreadPool(1));
Connect to the Scheduled Stream
{ @code HotStream<Data> dataStream = SequenceeM.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 Traversable<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
SequenceeM.generate(()->"next job:"+formatDate(new Date()))
.map(this::processJob)
.scheduleFixedRate(60_000,Executors.newScheduledThreadPool(1));
Connect to the Scheduled Stream
{ @code HotStream<Data> dataStream = SequenceeM.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 Traversable<T>
rate
- Time in millis between job runsex
- ScheduledExecutorService@Deprecated public final <R> R unwrap()
unwrap
in interface ReactiveSeq<T>
unwrap
in interface Unwrapable
public final <T1> ReactiveSeq<T1> flatten()
assertThat(SequenceM.<Integer>of(Arrays.asList(1,2)).flatten().toList().size(),equalTo(asList(1, 2).size()));
// or more advanced example
AnyM<AnyM<Integer>> applied =anyM(Optional.of(2))
.simpleFilter(anyM(Streamable.of( (Integer a)->a>5 ,(Integer a) -> a<3)));
assertThat(applied.toSequence().flatten().toList(),equalTo(Arrays.asList(2)));
flatten
in interface ReactiveSeq<T>
public final java.util.stream.Stream<T> unwrapStream()
Stream<String> stream = anyM("hello","world").asSequence().unwrapStream();
assertThat(stream.collect(Collectors.toList()),equalTo(Arrays.asList("hello","world")));
public final ReactiveSeq<T> cycle(int times)
assertThat(anyM(Stream.of(1,2,2)).asSequence()
.cycle(3).collect(Collectors.toList()),
equalTo(Arrays.asList(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()
assertEquals(asList(1, 1, 1, 1, 1,1),of(1).cycle().limit(6).toList());
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()
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()
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()
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.of(1,2,3).splitAtHead()
//Optional[1], SequenceM[2,3]
splitSequenceAtHead
in interface ReactiveSeq<T>
public final org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> splitAt(int where)
ReactiveSeq.of(1,2,3).splitAt(1)
//SequenceM[1], SequenceM[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.of(1, 2, 3, 4, 5, 6).splitBy(i->i<4)
//SequenceM[1,2,3] SequenceM[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.of(1, 2, 3, 4, 5, 6).partition(i -> i % 2 != 0)
//SequenceM[1,3,5], SequenceM[2,4,6]
partitionSequence
in interface ReactiveSeq<T>
public final ReactiveSeq<T> cycle(Monoid<T> m, int times)
List<Integer> list = AsGenericMonad,asStreamUtils.sequenceM(Stream.of(1,2,2))
.cycle(Reducers.toCountInt(),3)
.collect(Collectors.toList());
//is asList(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 <R> ReactiveSeq<R> cycle(java.lang.Class<R> monadC, int times)
{ @code List<Optional<Integer>> list = StreamUtils.sequenceM(Stream.of(1, 2)).cycle(Optional.class, 2).toList(); // is asList(Optional.of(1),Optional.of(2),Optional.of(1),Optional.of(2) )); }
monadC
- class typetimes
- public final ReactiveSeq<T> cycleWhile(java.util.function.Predicate<? super T> predicate)
count =0;
assertThat(anyM(Stream.of(1,2,2)).asSequence()
.cycleWhile(next -> count++<6)
.collect(Collectors.toList()),equalTo(Arrays.asList(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)
count =0;
assertThat(anyM(Stream.of(1,2,2)).asSequence()
.cycleUntil(next -> count++>6)
.collect(Collectors.toList()),equalTo(Arrays.asList(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<S> second)
List<Tuple2<Integer, String>> list = of(1, 2).zip(of("a", "b", "c", "d")).toList();
// [[1,"a"],[2,"b"]]
zip
in interface org.jooq.lambda.Seq<T>
public 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)
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<T2> second, java.util.stream.Stream<T3> third, java.util.stream.Stream<T4> fourth)
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> zipSequence(ReactiveSeq<? extends S> second, java.util.function.BiFunction<? super T,? super S,? extends R> zipper)
{ @code Stream<List<Integer>> zipped = asStreamUtils.sequenceM(Stream.of(1, 2, 3)).zip( asStreamUtils.sequenceM(Optional.of(2)), (a, b) -> Arrays.asList(a, b)); // [[1,2]] }
zipSequence
in interface ReactiveSeq<T>
second
- Monad to zip withzipper
- Zipping functionpublic final <S,R> ReactiveSeq<R> zipAnyM(AnyM<? extends S> second, java.util.function.BiFunction<? super T,? super S,? extends R> zipper)
Stream<List<Integer>> zipped = anyM(Stream.of(1,2,3))
.asSequence()
.zip(anyM(Optional.of(2)),
(a,b) -> Arrays.asList(a,b)).toStream();
List<Integer> zip = zipped.collect(Collectors.toList()).get(0);
assertThat(zip.get(0),equalTo(1));
assertThat(zip.get(1),equalTo(2));
zipAnyM
in interface ReactiveSeq<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)
{ @code Stream<List<Integer>> zipped = asStreamUtils.sequenceM(Stream.of(1, 2, 3)).zip( 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)
List<List<Integer>> list = anyM(Stream.of(1,2,3,4,5,6))
.asSequence()
.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)
List<List<Integer>> list = anyM(Stream.of(1,2,3,4,5,6))
.asSequence()
.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)
{ @code List<List<Integer>> list = StreamUtils.sequenceM(Stream.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>> groupedStatefullyWhile(java.util.function.BiPredicate<ListX<? super T>,? super T> predicate)
ReactiveSeq
assertThat(ReactiveSeq.of(1,2,3,4,5,6)
.groupedStatefullyWhile((s,i)-> s.contains(4) ? true : false)
.toList().size(),equalTo(5));
groupedStatefullyWhile
in interface ReactiveSeq<T>
groupedStatefullyWhile
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)
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());
groupBy
in interface ReactiveSeq<T>
groupBy
in interface Traversable<T>
groupBy
in interface org.jooq.lambda.Seq<T>
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)
assertEquals(asList("", "a", "ab", "abc"),StreamUtils.sequenceM(Stream.of("a", "b", "c")).scanLeft(Reducers.toString("")).toList());
scanLeft
in interface ReactiveSeq<T>
scanLeft
in interface Traversable<T>
monoid
- public final <U> ReactiveSeq<U> scanLeft(U seed, java.util.function.BiFunction<U,? super T,U> function)
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)
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,U,U> combiner)
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()
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)
assertThat(anyM(Stream.of(4,3,6,7)).asSequence().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)
assertThat(anyM(Stream.of(4,3,6,7)).asSequence().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)
assertThat(anyM(Stream.of(4,3,6,7)).asSequence().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)
assertThat(anyM(Stream.of(4,3,6,7)).asSequence().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)
assertThat(anyM(Stream.of(4,3,6,7)).asSequence().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)
assertThat(anyM(Stream.of(4,3,6,7)).asSequence().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)
assertThat(anyM(Stream.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)
assertThat(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)
assertThat(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)
assertTrue(ReactiveSeq.of(1,2,3,5,6,7).xMatch(3, i-> i>4 ));
xMatch
in interface ReactiveSeq<T>
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()
assertEquals("123".length(),of(1, 2, 3).join().length());
join
in interface ReactiveSeq<T>
join
in interface Foldable<T>
join
in interface Traversable<T>
join
in interface org.jooq.lambda.Seq<T>
public final java.lang.String join(java.lang.String sep)
assertEquals("1, 2, 3".length(), of(1, 2, 3).join(", ").length());
join
in interface ReactiveSeq<T>
join
in interface Foldable<T>
join
in interface Traversable<T>
public final 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());
join
in interface ReactiveSeq<T>
join
in interface Foldable<T>
join
in interface Traversable<T>
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()
ReactiveSeq<String> helloWorld = ReactiveSeq.of("hello","world","last");
HeadAndTail<String> headAndTail = helloWorld.headAndTail();
String head = headAndTail.head();
assertThat(head,equalTo("hello"));
ReactiveSeq<String> tail = headAndTail.tail();
assertThat(tail.headAndTail().head(),equalTo("world"));
headAndTail
in interface ReactiveSeq<T>
headAndTail
in interface Traversable<T>
public final java.util.Optional<T> findFirst()
findFirst
in interface ReactiveSeq<T>
findFirst
in interface Traversable<T>
findFirst
in interface java.util.stream.Stream<T>
public final java.util.Optional<T> findAny()
findAny
in interface ReactiveSeq<T>
findAny
in interface Traversable<T>
findAny
in interface java.util.stream.Stream<T>
public final <R> R mapReduce(Reducer<R> reducer)
public final <R> R mapReduce(java.util.function.Function<? super T,? extends R> mapper, Monoid<R> reducer)
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>
collector
- Collection operation definitionpublic 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 <U> U reduce(U identity, java.util.function.BiFunction<U,? super T,U> accumulator, java.util.function.BinaryOperator<U> combiner)
public final ListX<T> reduce(java.util.stream.Stream<? extends Monoid<T>> reducers)
public final ListX<T> reduce(java.lang.Iterable<? extends Monoid<T>> reducers)
public final T foldLeft(Monoid<T> reducer)
reducer
- Use supplied Monoid to reduce values starting via foldLeftpublic final T foldLeft(T identity, java.util.function.BinaryOperator<T> accumulator)
assertTrue(ReactiveSeq.of("a", "b", "c").foldLeft("", String::concat).equals("abc"));
public final <T> T foldLeftMapToType(Reducer<T> reducer)
reducer
- Monoid to reduce valuespublic 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,U,U> function)
assertTrue(ReactiveSeq.of("a","b","c").foldRight("", String::concat).equals("cba"));
public final <T> T foldRightMapToType(Reducer<T> reducer)
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.sequenceM().toList(); //Arrays.asList(2,4,6,8,10,12));
repeat.sequenceM().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()
ReactiveSeq
toStream
in interface ReactiveSeq<T>
public final ReactiveSeq<T> stream()
stream
in interface ReactiveSeq<T>
stream
in interface Foldable<T>
stream
in interface IterableFunctor<T>
stream
in interface ConvertableSequence<T>
stream
in interface Traversable<T>
stream
in interface org.jooq.lambda.Seq<T>
public final boolean startsWithIterable(java.lang.Iterable<T> iterable)
assertTrue(StreamUtils.sequenceM(Stream.of(1,2,3,4)).startsWith(Arrays.asList(1,2,3)));
startsWithIterable
in interface ReactiveSeq<T>
startsWithIterable
in interface Traversable<T>
iterable
- public final boolean startsWith(java.util.Iterator<T> iterator)
assertTrue(StreamUtils.sequenceM(Stream.of(1,2,3,4)).startsWith(Arrays.asList(1,2,3).iterator()))
startsWith
in interface ReactiveSeq<T>
startsWith
in interface Traversable<T>
iterator
- public AnyMSeq<T> anyM()
anyM
in interface ReactiveSeq<T>
public final <R> ReactiveSeq<R> map(java.util.function.Function<? super T,? extends R> fn)
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>
public final ReactiveSeq<T> peek(java.util.function.Consumer<? super T> c)
public final <R> ReactiveSeq<R> flatMap(java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends R>> fn)
assertThat(this.<Integer>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)
assertThat(anyM(Seq.of(1,2,3)).asSequence().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,java.lang.Iterable<? extends R>> fn)
AnyM<Integer> opt = anyM(Optional.of(20));
Optional<List<Integer>> optionalList = opt.flatMap( i -> anyM(Stream.of(1,2,i))).unwrap();
//Optional [1,2,20]
In such cases using Arrays.asList would be more performant
AnyM<Integer> opt = anyM(Optional.of(20));
Optional<List<Integer>> optionalList = opt.flatMapCollection( i -> asList(1,2,i))).unwrap();
//Optional [1,2,20]
flatMapIterable
in interface ReactiveSeq<T>
fn
- public final <R> ReactiveSeq<R> flatMapStream(java.util.function.Function<? super T,java.util.stream.BaseStream<? extends R,?>> fn)
assertThat(anyM(Stream.of(1,2,3)).asSequence().flatMapStream(i->Stream.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)
assertThat(ReactiveSeq.of(1,2,3,null).flatMapOptional(Optional::ofNullable)
.collect(Collectors.toList()),
equalTo(Arrays.asList(1,2,3)));
fn
- public final <R> ReactiveSeq<R> flatMapCompletableFuture(java.util.function.Function<? super T,java.util.concurrent.CompletableFuture<? extends R>> fn)
assertThat(ReactiveSeq.of(1,2,3).flatMapCompletableFuture(i->CompletableFuture.completedFuture(i+2))
.collect(Collectors.toList()),
equalTo(Arrays.asList(3,4,5)));
fn
- public final ReactiveSeq<java.lang.Character> flatMapCharSequence(java.util.function.Function<? super T,java.lang.CharSequence> fn)
List<Character> result = anyM("input.file")
.asSequence()
.flatMapCharSequence(i->"hello world")
.toList();
assertThat(result,equalTo(Arrays.asList('h','e','l','l','o',' ','w','o','r','l','d')));
fn
- public final ReactiveSeq<java.lang.String> flatMapFile(java.util.function.Function<? super T,java.io.File> fn)
List<String> result = anyM("input.file")
.asSequence()
.map(getClass().getClassLoader()::getResource)
.peek(System.out::println)
.map(URL::getFile)
.liftAndBindFile(File::new)
.toList();
assertThat(result,equalTo(Arrays.asList("hello","world")));
fn
- public final ReactiveSeq<java.lang.String> flatMapURL(java.util.function.Function<? super T,java.net.URL> fn)
List<String> result = anyM("input.file")
.asSequence()
.liftAndBindURL(getClass().getClassLoader()::getResource)
.toList();
assertThat(result,equalTo(Arrays.asList("hello","world")));
fn
- public final ReactiveSeq<java.lang.String> flatMapBufferedReader(java.util.function.Function<? super T,java.io.BufferedReader> fn)
Listresult = anyM("input.file") .asSequence() .map(getClass().getClassLoader()::getResourceAsStream) .map(InputStreamReader::new) .liftAndBindBufferedReader(BufferedReader::new) .toList(); assertThat(result,equalTo(Arrays.asList("hello","world")));
fn
- public final ReactiveSeq<T> filter(java.util.function.Predicate<? super T> fn)
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>
public 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)
intersperse
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<U> type)
ofType
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<U> type)
ClassCastException
.
// ClassCastException ReactiveSeq.of(1, "a", 2, "b", 3).cast(Integer.class)public CollectionX<T> toLazyCollection()
Collection<Integer> col = ReactiveSeq.of(1,2,3,4,5)
.peek(System.out::println)
.toLazyCollection();
System.out.println("first!");
col.forEach(System.out::println);
//Will print out "first!" before anything else
toLazyCollection
in interface ReactiveSeq<T>
toLazyCollection
in interface Traversable<T>
public CollectionX<T> toConcurrentLazyCollection()
Collection<Integer> col = ReactiveSeq.of(1,2,3,4,5)
.peek(System.out::println)
.toConcurrentLazyCollection();
System.out.println("first!");
col.forEach(System.out::println);
//Will print out "first!" before anything else
toConcurrentLazyCollection
in interface ReactiveSeq<T>
toConcurrentLazyCollection
in interface Traversable<T>
public Streamable<T> toLazyStreamable()
public Streamable<T> toConcurrentLazyStreamable()
ReactiveSeq
{ @code Streamable<Integer> repeat = ReactiveSeq.of(1, 2, 3, 4, 5, 6).map(i -> i + 2).toConcurrentLazyStreamable(); assertThat(repeat.sequenceM().toList(), equalTo(Arrays.asList(2, 4, 6, 8, 10, 12))); assertThat(repeat.sequenceM().toList(), equalTo(Arrays.asList(2, 4, 6, 8, 10, 12))); }
toConcurrentLazyStreamable
in interface ReactiveSeq<T>
toConcurrentLazyStreamable
in interface Traversable<T>
public ReactiveSeq<T> reverse()
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)
List<String> result = of(1,2,3).appendStream(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)
List<String> result = 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)
List<String> result = 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)
List<String> result = 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)
List<String> result = 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)
List<String> result = 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)
List<String> result = 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)
ReactiveSeq
futureOperations
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 Traversable<T>
iterable
- Values to checkpublic HotStream<T> hotStream(java.util.concurrent.Executor e)
ReactiveSeq
ReactiveSeq.primedHotStream(Executor)
.
The generated HotStream is not pausable, for a pausable HotStream @see ReactiveSeq.pausableHotStream(Executor)
.
Turns this SequenceM into a HotStream, a connectable Stream, being
executed on a thread on the supplied executor, that is producing data
HotStream<Integer> ints = SequenceM.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 SequenceM 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 Traversable<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<U> other)
ReactiveSeq
{ @code 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 org.jooq.lambda.Seq<T>
public ReactiveSeq<T> onEmpty(T value)
onEmpty
in interface ReactiveSeq<T>
onEmpty
in interface Traversable<T>
onEmpty
in interface org.jooq.lambda.Seq<T>
public ReactiveSeq<T> onEmptyGet(java.util.function.Supplier<T> supplier)
onEmptyGet
in interface ReactiveSeq<T>
onEmptyGet
in interface Traversable<T>
onEmptyGet
in interface org.jooq.lambda.Seq<T>
public <X extends java.lang.Throwable> ReactiveSeq<T> onEmptyThrow(java.util.function.Supplier<X> supplier)
onEmptyThrow
in interface ReactiveSeq<T>
onEmptyThrow
in interface Traversable<T>
onEmptyThrow
in interface org.jooq.lambda.Seq<T>
public ReactiveSeq<T> concat(java.util.stream.Stream<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<U> other, java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
zip
in interface ReactiveSeq<T>
zip
in interface org.jooq.lambda.Seq<T>
public 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 <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> zipStream(java.util.stream.Stream<U> other)
ReactiveSeq
{ @code List<Tuple2<Integer, String>> list = of(1, 2).zip(of("a", "b", "c", "d")).toList(); // [[1,"a"],[2,"b"]] }
zipStream
in interface ReactiveSeq<T>
zipStream
in interface Traversable<T>
public ReactiveSeq<T> xPer(int x, long time, java.util.concurrent.TimeUnit t)
ReactiveSeq
{ @code SimpleTimer timer = new SimpleTimer(); assertThat(ReactiveSeq.of(1, 2, 3, 4, 5, 6).xPer(6, 100000000, TimeUnit.NANOSECONDS).collect(Collectors.toList()).size(), is(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
SequenceM.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>
public ReactiveSeq<ListX<T>> groupedBySizeAndTime(int size, long time, java.util.concurrent.TimeUnit t)
ReactiveSeq
ReactiveSeq.of(1,2,3,4,5,6)
.batchBySizeAndTime(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)));
endsWith
in interface ReactiveSeq<T>
endsWith
in interface Traversable<T>
iterable
- Values to checkpublic ReactiveSeq<T> skip(long time, java.util.concurrent.TimeUnit unit)
ReactiveSeq
{ @code 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
{ @code 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
{ @code SimpleTimer timer = new SimpleTimer(); assertThat(ReactiveSeq.of(1, 2, 3, 4, 5, 6).fixedDelay(10000, TimeUnit.NANOSECONDS).collect(Collectors.toList()).size(), is(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(); assertThat(ReactiveSeq.of(1, 2, 3, 4, 5, 6).jitter(10000).collect(Collectors.toList()).size(), is(6)); 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
{ @code List<ArrayList<Integer>> list = of(1, 2, 3, 4, 5, 6).batchBySizeAndTime(10, 1, TimeUnit.MICROSECONDS, () -> new ArrayList<>()).toList(); }
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)
ReactiveSeq
skipLast
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 <R1,R2,R> ReactiveSeq<R> forEach3(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1, java.util.function.Function<? super T,java.util.function.Function<? super R1,? extends java.util.stream.BaseStream<R2,?>>> stream2, java.util.function.Function<? super T,java.util.function.Function<? super R1,java.util.function.Function<? super R2,? extends R>>> yieldingFunction)
ReactiveSeq.of(1,2)
.forEach3(a->IntStream.range(10,13),
.a->b->Stream.of(""+(a+b),"hello world"),
a->b->c->c+":"a+":"+b);
//SequenceM[11:1:2,hello world:1:2,14:1:4,hello world:1:4,12:1:2,hello world:1:2,15:1:5,hello world:1:5]
forEach3
in interface ReactiveSeq<T>
stream1
- Nested Stream to iterate overstream2
- Nested Stream to iterate overyieldingFunction
- Function with pointers to the current element from both Streams that generates the new elementspublic <R1,R2,R> ReactiveSeq<R> forEach3(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1, java.util.function.Function<? super T,java.util.function.Function<? super R1,? extends java.util.stream.BaseStream<R2,?>>> stream2, java.util.function.Function<? super T,java.util.function.Function<? super R1,java.util.function.Function<? super R2,java.lang.Boolean>>> filterFunction, java.util.function.Function<? super T,java.util.function.Function<? super R1,java.util.function.Function<? super R2,? extends R>>> yieldingFunction)
forEach3
in interface ReactiveSeq<T>
stream1
- Nested Stream to iterate overstream2
- Nested Stream to iterate overfilterFunction
- Filter to apply over elements before passing non-filtered values to the yielding functionyieldingFunction
- Function with pointers to the current element from both Streams that generates the new elementspublic <R1,R> ReactiveSeq<R> forEach2(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1, java.util.function.Function<? super T,java.util.function.Function<? super R1,? extends R>> yieldingFunction)
ReactiveSeq.of(1,2,3)
.forEach2(a->IntStream.range(10,13),
a->b->a+b);
/SequenceM[11,14,12,15,13,16]
forEach2
in interface ReactiveSeq<T>
stream1
- Nested Stream to iterate overyieldingFunction
- Function with pointers to the current element from both Streams that generates the new elementspublic <R1,R> ReactiveSeq<R> forEach2(java.util.function.Function<? super T,? extends java.util.stream.BaseStream<R1,?>> stream1, java.util.function.Function<? super T,java.util.function.Function<? super R1,java.lang.Boolean>> filterFunction, java.util.function.Function<? super T,java.util.function.Function<? super R1,? extends R>> yieldingFunction)
ReactiveSeq.of(1,2,3)
.forEach2(a->IntStream.range(10,13),
a->b-> a<3 && b>10,
a->b->a+b);
//SequenceM[14,15]
forEach2
in interface ReactiveSeq<T>
stream1
- Nested Stream to iterate overfilterFunction
- Filter to apply over elements before passing non-filtered values to the yielding functionyieldingFunction
- Function with pointers to the current element from both Streams that generates the new elementspublic <X extends java.lang.Throwable> org.reactivestreams.Subscription forEachX(long numberOfElements, java.util.function.Consumer<? super T> consumer)
ReactiveStreamsTerminalOperations
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
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
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
forEachWithError
in interface ReactiveStreamsTerminalOperations<T>
consumerError
- 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
forEachEvent
in interface ReactiveStreamsTerminalOperations<T>
consumerError
- To accept incoming processing errors from the StreamonComplete
- To run after an onComplete eventpublic HotStream<T> primedHotStream(java.util.concurrent.Executor e)
ReactiveSeq
ReactiveSeq.hotStream(Executor)
.
The generated HotStream is not pausable, for a pausable HotStream @see ReactiveSeq.primedPausableHotStream(Executor)
.
HotStream<Integer> ints = SequenceM.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)
ReactiveSeq
ReactiveSeq.primedPausableHotStream(Executor)
.
The generated HotStream is pausable, for a unpausable HotStream (slightly faster execution) @see ReactiveSeq.hotStream(Executor)
.
HotStream<Integer> ints = SequenceM.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 SequenceM onpublic PausableHotStream<T> primedPausableHotStream(java.util.concurrent.Executor e)
ReactiveSeq
ReactiveSeq.pausableHotStream(Executor)
.
The generated HotStream is pausable, for a unpausable HotStream @see ReactiveSeq.primedHotStream(Executor)
.
HotStream<Integer> ints = SequenceM.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()
CyclopsCollectable
collectable
in interface ReactiveSeq<T>
collectable
in interface IterableFunctor<T>
collectable
in interface CyclopsCollectable<T>
public <T> ReactiveSeq<T> unitIterator(java.util.Iterator<T> it)
unitIterator
in interface ReactiveSeq<T>
unitIterator
in interface IterableFunctor<T>
public 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>