public interface ReactiveSeq<T> extends Unwrapable, java.util.stream.Stream<T>, JoolManipulation<T>, IterableFilterable<T>, FilterableFunctor<T>, ExtendedTraversable<T>, IterableFoldable<T>, CyclopsCollectable<T>, JoolWindowing<T>, org.jooq.lambda.Seq<T>, java.lang.Iterable<T>, org.reactivestreams.Publisher<T>, ReactiveStreamsTerminalOperations<T>, ZippingApplicativable<T>, Unit<T>, ConvertableSequence<T>
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
|
default <R> ZippingApplicativable<R> |
ap1(java.util.function.Function<? super T,? extends R> fn) |
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
|
default <R> ApplyingZippingApplicativeBuilder<T,R,ZippingApplicativable<R>> |
applicatives() |
default java.util.Optional<T> |
avg() |
default <U> java.util.Optional<U> |
avg(java.util.function.Function<? super T,? extends U> function) |
default double |
avgDouble(java.util.function.ToDoubleFunction<? super T> function) |
default double |
avgInt(java.util.function.ToIntFunction<? super T> function) |
default double |
avgLong(java.util.function.ToLongFunction<? super T> function) |
<U> ReactiveSeq<U> |
cast(java.lang.Class<? extends U> type)
Cast all elements in a stream to a given type, possibly throwing a
ClassCastException . |
default <R,A> R |
collect(java.util.stream.Collector<? super T,A,R> collector) |
default org.jooq.lambda.Collectable<T> |
collectable()
Narrow this class to a Collectable
|
default ReactiveSeq<ReactiveSeq<T>> |
combinations()
ReactiveSeq.of(1,2,3).combinations()
//ReactiveSeq[ReactiveSeq[],ReactiveSeq[1],ReactiveSeq[2],ReactiveSeq[3].ReactiveSeq[1,2],ReactiveSeq[1,3],ReactiveSeq[2,3]
,ReactiveSeq[1,2,3]]
|
default ReactiveSeq<ReactiveSeq<T>> |
combinations(int size)
ReactiveSeq.of(1,2,3).combinations(2)
//ReactiveSeq[ReactiveSeq[1,2],ReactiveSeq[1,3],ReactiveSeq[2,3]]
|
default ReactiveSeq<T> |
combine(java.util.function.BiPredicate<? super T,? super T> predicate,
java.util.function.BinaryOperator<T> op)
Combine two adjacent elements in a traversable using the supplied BinaryOperator
This is a stateful grouping & reduction operation.
|
ReactiveSeq<T> |
concat(java.util.stream.Stream<? extends T> other) |
ReactiveSeq<T> |
concat(T... other) |
ReactiveSeq<T> |
concat(T other) |
default long |
count() |
default long |
count(java.util.function.Predicate<? super T> predicate) |
default long |
countDistinct() |
default long |
countDistinct(java.util.function.Predicate<? super T> predicate) |
default <U> long |
countDistinctBy(java.util.function.Function<? super T,? extends U> function) |
default <U> long |
countDistinctBy(java.util.function.Function<? super T,? extends U> function,
java.util.function.Predicate<? super U> predicate) |
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
crossJoin(java.lang.Iterable<? extends U> other) |
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
crossJoin(org.jooq.lambda.Seq<? extends U> other) |
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
crossJoin(java.util.stream.Stream<? extends U> other) |
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) |
default ReactiveSeq<T> |
dropRight(int num) |
default ReactiveSeq<T> |
dropUntil(java.util.function.Predicate<? super T> p) |
default ReactiveSeq<T> |
dropWhile(java.util.function.Predicate<? super T> p) |
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.
|
default ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,java.lang.Long>> |
elapsed()
ReactiveSeq.of(1,2,3,4,5)
.elapsed()
.forEach(System.out::println);
|
default org.jooq.lambda.tuple.Tuple2<T,ReactiveSeq<T>> |
elementAt(long index)
Gets the element at index, and returns a Tuple containing the element (it
must be present) and a lazy copy of the Sequence for further processing.
|
static <T> ReactiveSeq<T> |
empty() |
boolean |
endsWith(java.util.stream.Stream<T> stream)
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
|
<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> |
flatMapStream(java.util.function.Function<? super T,java.util.stream.BaseStream<? extends R,?>> fn)
flatMap operation
|
<T1> ReactiveSeq<T1> |
flatten()
join / flatten one level of a nested hierarchy
|
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
|
default <U> U |
foldRight(U identity,
java.util.function.BiFunction<? super T,? super U,? extends U> accumulator) |
<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
|
<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
|
static ReactiveSeq<java.lang.Double> |
fromDoubleStream(java.util.stream.DoubleStream stream)
Construct a ReactiveSeq from a Stream
|
static ReactiveSeq<java.lang.Integer> |
fromIntStream(java.util.stream.IntStream stream)
Construct a ReactiveSeq from a Stream
|
static <T> ReactiveSeq<T> |
fromIterable(java.lang.Iterable<T> iterable)
Construct a ReactiveSeq from an Iterable
|
static <T> ReactiveSeq<T> |
fromIterator(java.util.Iterator<T> iterator)
Construct a ReactiveSeq from an Iterator
|
static <T> ReactiveSeq<T> |
fromList(java.util.List<T> list)
Construct a ReactiveSeq from a List (prefer this method if the source is a
list, as it allows more efficient Stream reversal).
|
static ReactiveSeq<java.lang.Long> |
fromLongStream(java.util.stream.LongStream stream)
Construct a ReactiveSeq from a Stream
|
static <T> ReactiveSeq<T> |
fromPublisher(org.reactivestreams.Publisher<? extends T> publisher)
Construct a ReactiveSeq from an Publisher
|
static <T> ReactiveSeq<T> |
fromStream(java.util.stream.Stream<T> stream)
Construct a ReactiveSeq from a Stream
|
FutureOperations<T> |
futureOperations(java.util.concurrent.Executor exec)
Access asynchronous terminal operations (each returns a Future)
|
static <T> ReactiveSeq<T> |
generate(java.util.function.Supplier<T> s) |
default java.util.Optional<T> |
get(long index)
Return the elementAt index or Optional.empty
|
default <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
|
default <K> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<K,org.jooq.lambda.Seq<T>>> |
grouped(java.util.function.Function<? super T,? extends K> classifier) |
default <K,A,D> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<K,D>> |
grouped(java.util.function.Function<? super T,? extends K> classifier,
java.util.stream.Collector<? super T,A,D> downstream) |
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> supplier)
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 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
|
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.
|
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
innerJoin(java.lang.Iterable<? extends U> other,
java.util.function.BiPredicate<? super T,? super U> predicate) |
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
innerJoin(org.jooq.lambda.Seq<? extends U> other,
java.util.function.BiPredicate<? super T,? super U> predicate) |
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
innerJoin(java.util.stream.Stream<? extends U> other,
java.util.function.BiPredicate<? super T,? super U> predicate) |
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
innerJoin(Streamable<? extends U> other,
java.util.function.BiPredicate<? super T,? super U> predicate) |
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.
|
static <T> ReactiveSeq<T> |
iterate(T seed,
java.util.function.UnaryOperator<T> f) |
ReactiveSeq<T> |
jitter(long maxJitterPeriodInNanos)
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());
|
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
leftOuterJoin(java.lang.Iterable<? extends U> other,
java.util.function.BiPredicate<? super T,? super U> predicate) |
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
leftOuterJoin(org.jooq.lambda.Seq<? extends U> other,
java.util.function.BiPredicate<? super T,? super U> predicate) |
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
leftOuterJoin(java.util.stream.Stream<? extends U> other,
java.util.function.BiPredicate<? super T,? super U> predicate) |
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
leftOuterJoin(Streamable<? extends U> s,
java.util.function.BiPredicate<? super T,? super U> predicate) |
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.
|
default ReactiveSeq<T> |
limitUntilClosed(java.util.function.Predicate<? super T> p) |
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
|
default java.util.Optional<T> |
max() |
default java.util.Optional<T> |
max(java.util.Comparator<? super T> comparator) |
default <U extends java.lang.Comparable<? super U>> |
max(java.util.function.Function<? super T,? extends U> function) |
default <U> java.util.Optional<U> |
max(java.util.function.Function<? super T,? extends U> function,
java.util.Comparator<? super U> comparator) |
default <U extends java.lang.Comparable<? super U>> |
maxBy(java.util.function.Function<? super T,? extends U> function) |
default <U> java.util.Optional<T> |
maxBy(java.util.function.Function<? super T,? extends U> function,
java.util.Comparator<? super U> comparator) |
default java.util.Optional<T> |
median() |
default java.util.Optional<T> |
median(java.util.Comparator<? super T> comparator) |
default <U extends java.lang.Comparable<? super U>> |
medianBy(java.util.function.Function<? super T,? extends U> function) |
default <U> java.util.Optional<T> |
medianBy(java.util.function.Function<? super T,? extends U> function,
java.util.Comparator<? super U> comparator) |
default java.util.Optional<T> |
min() |
default java.util.Optional<T> |
min(java.util.Comparator<? super T> comparator) |
default <U extends java.lang.Comparable<? super U>> |
min(java.util.function.Function<? super T,? extends U> function) |
default <U> java.util.Optional<U> |
min(java.util.function.Function<? super T,? extends U> function,
java.util.Comparator<? super U> comparator) |
default <U extends java.lang.Comparable<? super U>> |
minBy(java.util.function.Function<? super T,? extends U> function) |
default <U> java.util.Optional<T> |
minBy(java.util.function.Function<? super T,? extends U> function,
java.util.Comparator<? super U> comparator) |
default java.util.Optional<T> |
mode() |
boolean |
noneMatch(java.util.function.Predicate<? super T> c) |
static <T> ReactiveSeq<T> |
of(T... elements)
Create an efficiently reversable Sequence from the provided elements
|
<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) |
ReactiveSeq<T> |
onEmptyGet(java.util.function.Supplier<? extends T> supplier) |
default ReactiveSeq<T> |
onEmptySwitch(java.util.function.Supplier<? extends java.util.stream.Stream<T>> switchTo)
If this ReactiveSeq is empty replace it with a another Stream
|
default <X extends java.lang.Throwable> |
onEmptyThrow(java.util.function.Supplier<? extends 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
|
default <R> ReactiveSeq<R> |
patternMatch(java.util.function.Function<Matchable.CheckValue1<T,R>,Matchable.CheckValue1<T,R>> case1,
java.util.function.Supplier<? extends R> otherwise)
Transform the elements of this Stream with a Pattern Matching case and default 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
|
default java.util.Optional<T> |
percentile(double percentile) |
default java.util.Optional<T> |
percentile(double percentile,
java.util.Comparator<? super T> comparator) |
default <U extends java.lang.Comparable<? super U>> |
percentileBy(double percentile,
java.util.function.Function<? super T,? extends U> function) |
default <U> java.util.Optional<T> |
percentileBy(double percentile,
java.util.function.Function<? super T,? extends U> function,
java.util.Comparator<? super U> comparator) |
default ReactiveSeq<ReactiveSeq<T>> |
permutations()
Generate the permutations based on values in the ReactiveSeq Makes use of
Streamable to store intermediate stages in a collection
|
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.
|
default void |
print(java.io.PrintStream stream) |
default void |
print(java.io.PrintWriter writer) |
default void |
printErr() |
default void |
printOut() |
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.
|
static ReactiveSeq<java.lang.Integer> |
range(int start,
int end)
Create an efficiently reversable Sequence that produces the integers
between start and end
|
static ReactiveSeq<java.lang.Long> |
rangeLong(long start,
long end)
Create an efficiently reversable Sequence that produces the integers
between start and end
|
<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
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) |
<U> U |
reduce(U identity,
java.util.function.BiFunction<U,? super T,U> accumulator,
java.util.function.BinaryOperator<U> combiner) |
default ReactiveSeq<T> |
remove(T t)
Remove all occurances of the specified element from the ReactiveSeq
|
default <R> ReactiveSeq<R> |
retry(java.util.function.Function<? super T,? extends R> fn)
Retry a transformation if it fails.
|
default <R> ReactiveSeq<R> |
retry(java.util.function.Function<? super T,? extends R> fn,
int retries,
long delay,
java.util.concurrent.TimeUnit timeUnit)
Retry a transformation if it fails.
|
ReactiveSeq<T> |
reverse() |
static <T> ReactiveSeq<T> |
reversedListOf(java.util.List<T> elements)
Construct a Reveresed Sequence from the provided elements Can be reversed
(again) efficiently
|
static <T> ReactiveSeq<T> |
reversedOf(T... elements)
Construct a Reveresed Sequence from the provided elements Can be reversed
(again) efficiently
|
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
rightOuterJoin(java.lang.Iterable<? extends U> other,
java.util.function.BiPredicate<? super T,? super U> predicate) |
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
rightOuterJoin(org.jooq.lambda.Seq<? extends U> other,
java.util.function.BiPredicate<? super T,? super U> predicate) |
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
rightOuterJoin(java.util.stream.Stream<? extends U> other,
java.util.function.BiPredicate<? super T,? super U> predicate) |
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) |
default T |
single()
//1
ReactiveSeq.of(1).single();
//UnsupportedOperationException
ReactiveSeq.of().single();
//UnsupportedOperationException
ReactiveSeq.of(1,2,3).single();
|
default T |
single(java.util.function.Predicate<? super T> predicate) |
default java.util.Optional<T> |
singleOptional()
//Optional[1]
ReactiveSeq.of(1).singleOptional();
//Optional.empty
ReactiveSeq.of().singleOpional();
//Optional.empty
ReactiveSeq.of(1,2,3).singleOptional();
|
default int |
size()
[equivalent to count]
|
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
|
default ReactiveSeq<T> |
skipUntilClosed(java.util.function.Predicate<? super T> p) |
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
|
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> stream)
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
|
static <T> SeqSubscriber<T> |
subscriber()
Create a subscriber that can listen to Reactive Streams (simple-react,
RxJava AkkaStreams, Kontraktor, QuadarStreams etc)
|
default ReactiveSeq<T> |
subStream(int start,
int end)
Return a Stream with elements before the provided start index removed,
and elements after the provided end index removed
|
default java.util.Optional<T> |
sum() |
default <U> java.util.Optional<U> |
sum(java.util.function.Function<? super T,? extends U> function) |
default double |
sumDouble(java.util.function.ToDoubleFunction<? super T> function) |
default int |
sumInt(java.util.function.ToIntFunction<? super T> function) |
default long |
sumLong(java.util.function.ToLongFunction<? super T> function) |
default ReactiveSeq<T> |
takeRight(int num) |
default ReactiveSeq<T> |
takeUntil(java.util.function.Predicate<? super T> p) |
default ReactiveSeq<T> |
takeWhile(java.util.function.Predicate<? super T> p) |
default ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,java.lang.Long>> |
timestamp()
ReactiveSeq.of(1,2,3,4,5)
.timestamp()
.forEach(System.out::println)
|
<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()
{
@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 ReactiveSeq into a Collection.
|
java.util.List<T> |
toList() |
default <L extends java.util.List<T>> |
toList(java.util.function.Supplier<L> factory) |
default <K,V> java.util.Map<K,V> |
toMap(java.util.function.Function<? super T,? extends K> keyMapper,
java.util.function.Function<? super T,? extends V> valueMapper) |
java.util.Set<T> |
toSet() |
default <S extends java.util.Set<T>> |
toSet(java.util.function.Supplier<S> factory) |
<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.sequenceM().toList(); //Arrays.asList(2,4,6,8,10,12));
repeat.sequenceM().toList() //Arrays.asList(2,4,6,8,10,12));
|
default java.lang.String |
toString(java.lang.CharSequence delimiter) |
default java.lang.String |
toString(java.lang.CharSequence delimiter,
java.lang.CharSequence prefix,
java.lang.CharSequence suffix) |
default <R> ReactiveSeq<R> |
trampoline(java.util.function.Function<? super T,? extends Trampoline<? extends R>> mapper)
Performs a map operation that can call a recursive method without running out of stack space
|
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.
|
static <U,T> ReactiveSeq<T> |
unfold(U seed,
java.util.function.Function<? super U,java.util.Optional<org.jooq.lambda.tuple.Tuple2<T,U>>> unfolder)
Unfold a function into a ReactiveSeq
|
<T> ReactiveSeq<T> |
unit(T unit) |
<T> ReactiveSeq<T> |
unitIterator(java.util.Iterator<T> it) |
ReactiveSeq<T> |
unordered() |
<R> R |
unwrap()
Unwrap a wrapped value
|
static <T,U> org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<U>> |
unzip(ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> sequence)
Unzip a zipped Stream
|
static <T1,T2,T3> org.jooq.lambda.tuple.Tuple3<ReactiveSeq<T1>,ReactiveSeq<T2>,ReactiveSeq<T3>> |
unzip3(ReactiveSeq<org.jooq.lambda.tuple.Tuple3<T1,T2,T3>> sequence)
Unzip a zipped Stream into 3
|
static <T1,T2,T3,T4> |
unzip4(ReactiveSeq<org.jooq.lambda.tuple.Tuple4<T1,T2,T3,T4>> sequence)
Unzip a zipped Stream into 4
|
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
|
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
zip(java.lang.Iterable<? extends U> other) |
default <U,R> ReactiveSeq<R> |
zip(java.lang.Iterable<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends R> zipper) |
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
zip(org.jooq.lambda.Seq<? extends U> other)
Zip 2 streams into one
|
default <U,R> ReactiveSeq<R> |
zip(org.jooq.lambda.Seq<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends R> zipper) |
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> |
zip(java.util.stream.Stream<? extends U> other)
Zip 2 streams into one
|
default <U,R> ReactiveSeq<R> |
zip(java.util.stream.Stream<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends R> zipper) |
<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 Monad with a Stream
|
default ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,java.lang.Long>> |
zipWithIndex()
Add an index to the current Stream
|
filterNot, notNull, removeAll, removeAll, removeAll, removeAll, retainAll, retainAll, retainAll, retainAll
groupedStatefullyWhileT, groupedT, groupedUntilT, groupedWhileT, slidingT, slidingT
foldable, visit
bitAnd, bitAnd, bitAndInt, bitAndLong, bitOr, bitOr, bitOrInt, bitOrLong, commonPrefix, commonSuffix, maxAll, maxAll, maxAll, maxAll, maxAllBy, maxAllBy, minAll, minAll, minAll, minAll, minAllBy, minAllBy, modeAll, modeAllBy, modeBy, toMap
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, append, cast, close, concat, concat, 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, drop, duplicate, duplicate, findFirst, findSingle, flatMapToDouble, flatMapToInt, flatMapToLong, foldLeft, foldLeft, foldLeft, foldLeft, foldRight, foldRight, foldRight, forEach, format, 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, mapToDouble, mapToInt, mapToLong, ofType, partition, partition, prepend, 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, seq, seq, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, skip, skipUntil, skipUntilClosed, skipWhile, skipWhileClosed, skipWhileClosed, slice, sliding, sorted, splitAt, splitAt, splitAtHead, splitAtHead, spliterator, take, 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, zipWithIndex
builder, collect, concat, forEachOrdered, toArray, toArray
forEachEvent, forEachWithError, forEachX, forEachXEvents, forEachXWithError
ap2, ap3, ap4, ap5
flatMapPublisher, flatMapPublisher, flatMapPublisher, mergePublisher, mergePublisher
lazyOperations, traversable
seq, 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, toXorSecondary
<T> ReactiveSeq<T> unitIterator(java.util.Iterator<T> it)
unitIterator
in interface IterableFunctor<T>
<T> ReactiveSeq<T> unit(T unit)
default <U> U foldRight(U identity, java.util.function.BiFunction<? super T,? super U,? extends U> accumulator)
default void printOut()
default <R> ApplyingZippingApplicativeBuilder<T,R,ZippingApplicativable<R>> applicatives()
applicatives
in interface ZippingApplicativable<T>
default <R> ZippingApplicativable<R> ap1(java.util.function.Function<? super T,? extends R> fn)
ap1
in interface ZippingApplicativable<T>
default <U,R> ReactiveSeq<R> zip(java.lang.Iterable<? extends U> other, java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
zip
in interface org.jooq.lambda.Seq<T>
zip
in interface Traversable<T>
default <U,R> ReactiveSeq<R> zip(org.jooq.lambda.Seq<? extends U> other, java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
zip
in interface org.jooq.lambda.Seq<T>
zip
in interface Traversable<T>
default <U,R> ReactiveSeq<R> zip(java.util.stream.Stream<? extends U> other, java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
zip
in interface org.jooq.lambda.Seq<T>
zip
in interface Traversable<T>
<R> R unwrap()
Unwrapable
unwrap
in interface Unwrapable
<T1> ReactiveSeq<T1> flatten()
ReactiveSeq.of(Arrays.asList(1,2)).flatten();
//stream of (1, 2);
ReactiveSeq<T> cycle(int times)
ReactiveSeq.of(1,2,2)
.cycle(3)
.collect(Collectors.toList());
//List[1,2,2,1,2,2,1,2,2]
cycle
in interface Traversable<T>
times
- Times values should be repeated within a StreamReactiveSeq<T> cycle()
ReactiveSeq.of(1).cycle().limit(6).toList());
//List[1, 1, 1, 1, 1,1]
cycle
in interface org.jooq.lambda.Seq<T>
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> duplicateSequence()
{ @code 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)); }
org.jooq.lambda.tuple.Tuple3<ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>> triplicate()
{ @code Tuple3<ReactiveSeq<Tuple3<T1, T2, T3>>, ReactiveSeq<Tuple3<T1, T2, T3>>, ReactiveSeq<Tuple3<T1, T2, T3>>> Tuple3 = sequence.triplicate(); }
org.jooq.lambda.tuple.Tuple4<ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>,ReactiveSeq<T>> quadruplicate()
{ @code 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(); }
org.jooq.lambda.tuple.Tuple2<java.util.Optional<T>,ReactiveSeq<T>> splitSequenceAtHead()
ReactiveSeq.of(1,2,3).splitAtHead()
//Optional[1], ReactiveSeq[2,3]
org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<T>> splitAt(int where)
ReactiveSeq.of(1,2,3).splitAt(1)
//ReactiveSeq[1], ReactiveSeq[2,3]
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)
//ReactiveSeq[1,2,3] ReactiveSeq[4,5,6]
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)
//ReactiveSeq[1,3,5], ReactiveSeq[2,4,6]
ReactiveSeq<T> cycle(Monoid<T> m, int times)
List<Integer> list = ReactiveSeq.of(1,2,2))
.cycle(Reducers.toCountInt(),3)
.collect(Collectors.toList());
//List[3,3,3];
cycle
in interface Traversable<T>
m
- Monoid to be used in reductiontimes
- Number of times value should be repeatedReactiveSeq<T> cycleWhile(java.util.function.Predicate<? super T> predicate)
{ @code 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 Traversable<T>
predicate
- repeat while trueReactiveSeq<T> cycleUntil(java.util.function.Predicate<? super T> predicate)
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 Traversable<T>
predicate
- repeat while truedefault <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> zip(java.util.stream.Stream<? extends U> other)
{ @code 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>
zip
in interface Traversable<T>
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> zip(java.lang.Iterable<? extends U> other)
zip
in interface org.jooq.lambda.Seq<T>
zip
in interface Traversable<T>
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> zip(org.jooq.lambda.Seq<? extends U> other)
{ @code 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>
zip
in interface Traversable<T>
<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)
{ @code 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 Traversable<T>
<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)
{ @code 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 Traversable<T>
default ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,java.lang.Long>> zipWithIndex()
assertEquals(asList(new Tuple2("a", 0L), new Tuple2("b", 1L)), of("a", "b").zipWithIndex().toList());
zipWithIndex
in interface org.jooq.lambda.Seq<T>
zipWithIndex
in interface Traversable<T>
<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 = asMonad(Stream.of(1, 2, 3)).zip(Stream.of(2, 3, 4), (a, b) -> Arrays.asList(a, b)); // [[1,2][2,3][3,4]] }
second
- Stream to zip withzipper
- Zip funcitonReactiveSeq<ListX<T>> sliding(int windowSize)
{ @code 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 Traversable<T>
windowSize
- Size of sliding windowReactiveSeq<ListX<T>> sliding(int windowSize, int increment)
{ @code 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 Traversable<T>
windowSize
- number of elements in each batchincrement
- for each windowReactiveSeq<ListX<T>> grouped(int groupSize)
{ @code 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 Traversable<T>
groupSize
- Size of each GroupReactiveSeq<ListX<T>> groupedStatefullyWhile(java.util.function.BiPredicate<ListX<? super T>,? super T> predicate)
assertThat(ReactiveSeq.of(1,2,3,4,5,6)
.groupedStatefullyWhile((s,i)-> s.contains(4) ? true : false)
.toList().size(),equalTo(5));
groupedStatefullyWhile
in interface Traversable<T>
predicate
- Window while trueReactiveSeq<ListX<T>> groupedBySizeAndTime(int size, long time, java.util.concurrent.TimeUnit t)
ReactiveSeq.of(1,2,3,4,5,6)
.batchBySizeAndTime(3,10,TimeUnit.SECONDS)
.toList();
//[[1,2,3],[4,5,6]]
size
- Max size of a batchtime
- (Max) time period to build a single batch int
- time unit for batch<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)
{ @code List<ArrayList<Integer>> list = of(1, 2, 3, 4, 5, 6).batchBySizeAndTime(10, 1, TimeUnit.MICROSECONDS, () -> new ArrayList<>()).toList(); }
size
- Max size of a batchtime
- (Max) time period to build a single batch inunit
- time unit for batchfactory
- Collection factoryReactiveSeq<ListX<T>> groupedByTime(long time, java.util.concurrent.TimeUnit t)
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));
time
- - time period to build a single batch int
- time unit for batch<C extends java.util.Collection<? super T>> ReactiveSeq<C> groupedByTime(long time, java.util.concurrent.TimeUnit unit, java.util.function.Supplier<C> factory)
assertThat(ReactiveSeq.of(1,1,1,1,1,1)
.batchByTime(1500,TimeUnit.MICROSECONDS,()-> new TreeSet<>())
.toList()
.get(0)
.size(),is(1));
time
- - time period to build a single batch inunit
- time unit for batchfactory
- Collection factory<C extends java.util.Collection<? super T>> ReactiveSeq<C> grouped(int size, java.util.function.Supplier<C> supplier)
assertThat(ReactiveSeq.of(1,1,1,1,1,1)
.batchBySize(3,()->new TreeSet<>())
.toList()
.get(0)
.size(),is(1));
grouped
in interface Traversable<T>
size
- batch sizesupplier
- Collection factoryReactiveSeq<ListX<T>> groupedUntil(java.util.function.Predicate<? super T> predicate)
assertThat(ReactiveSeq.of(1,2,3,4,5,6)
.batchUntil(i->i%3==0)
.toList()
.size(),equalTo(2));
groupedUntil
in interface Traversable<T>
predicate
- Batch until predicate holds, then open next batchReactiveSeq<ListX<T>> groupedWhile(java.util.function.Predicate<? super T> predicate)
assertThat(ReactiveSeq.of(1,2,3,4,5,6)
.batchWhile(i->i%3!=0)
.toList().size(),equalTo(2));
groupedWhile
in interface Traversable<T>
predicate
- Batch while predicate holds, then open next batch<C extends java.util.Collection<? super T>> ReactiveSeq<C> groupedWhile(java.util.function.Predicate<? super T> predicate, java.util.function.Supplier<C> factory)
assertThat(ReactiveSeq.of(1,2,3,4,5,6)
.batchWhile(i->i%3!=0)
.toList()
.size(),equalTo(2));
groupedWhile
in interface Traversable<T>
predicate
- Batch while predicate holds, then open next batchfactory
- Collection factory<C extends java.util.Collection<? super T>> ReactiveSeq<C> groupedUntil(java.util.function.Predicate<? super T> predicate, java.util.function.Supplier<C> factory)
assertThat(ReactiveSeq.of(1,2,3,4,5,6)
.batchUntil(i->i%3!=0)
.toList()
.size(),equalTo(2));
groupedUntil
in interface Traversable<T>
predicate
- Batch until predicate holds, then open next batchfactory
- Collection factorydefault <K,A,D> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<K,D>> grouped(java.util.function.Function<? super T,? extends K> classifier, java.util.stream.Collector<? super T,A,D> downstream)
grouped
in interface org.jooq.lambda.Seq<T>
grouped
in interface Traversable<T>
default <K> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<K,org.jooq.lambda.Seq<T>>> grouped(java.util.function.Function<? super T,? extends K> classifier)
grouped
in interface org.jooq.lambda.Seq<T>
grouped
in interface Traversable<T>
default <K> MapX<K,java.util.List<T>> groupBy(java.util.function.Function<? super T,? extends K> classifier)
{ @code 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()); }
ReactiveSeq<T> distinct()
distinct
in interface org.jooq.lambda.Seq<T>
distinct
in interface java.util.stream.Stream<T>
distinct
in interface Traversable<T>
ReactiveSeq<T> scanLeft(Monoid<T> monoid)
assertEquals(asList("", "a", "ab", "abc"),ReactiveSeq.of("a", "b", "c")
.scanLeft(Reducers.toString("")).toList());
scanLeft
in interface Traversable<T>
monoid
- <U> ReactiveSeq<U> scanLeft(U seed, java.util.function.BiFunction<? super U,? super T,? extends U> function)
assertThat(of("a", "b", "c").scanLeft("", String::concat).toList().size(),
is(4));
scanLeft
in interface org.jooq.lambda.Seq<T>
scanLeft
in interface Traversable<T>
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 Traversable<T>
<U> ReactiveSeq<U> scanRight(U identity, java.util.function.BiFunction<? super T,? super U,? extends 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 org.jooq.lambda.Seq<T>
scanRight
in interface Traversable<T>
ReactiveSeq<T> sorted()
assertThat(ReactiveSeq.of(4,3,6,7)).sorted().toList(),equalTo(Arrays.asList(3,4,6,7)));
sorted
in interface org.jooq.lambda.Seq<T>
sorted
in interface java.util.stream.Stream<T>
sorted
in interface Traversable<T>
default ReactiveSeq<T> combine(java.util.function.BiPredicate<? super T,? super T> predicate, java.util.function.BinaryOperator<T> op)
Traversable
ReactiveSeq.of(1,1,2,3)
.combine((a, b)->a.equals(b),Semigroups.intSum)
.toListX()
//ListX(3,4)
combine
in interface Traversable<T>
predicate
- Test to see if two neighbours should be joinedop
- Reducer to combine neighboursReactiveSeq<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)));
sorted
in interface org.jooq.lambda.Seq<T>
sorted
in interface java.util.stream.Stream<T>
sorted
in interface Traversable<T>
c
- Compartor to sort withdefault ReactiveSeq<T> takeWhile(java.util.function.Predicate<? super T> p)
takeWhile
in interface Traversable<T>
default ReactiveSeq<T> dropWhile(java.util.function.Predicate<? super T> p)
dropWhile
in interface Traversable<T>
default ReactiveSeq<T> takeUntil(java.util.function.Predicate<? super T> p)
takeUntil
in interface Traversable<T>
default ReactiveSeq<T> dropUntil(java.util.function.Predicate<? super T> p)
dropUntil
in interface Traversable<T>
default ReactiveSeq<T> dropRight(int num)
dropRight
in interface Traversable<T>
default ReactiveSeq<T> takeRight(int num)
takeRight
in interface Traversable<T>
ReactiveSeq<T> skip(long num)
assertThat(ReactiveSeq.of(4,3,6,7).skip(2).toList(),equalTo(Arrays.asList(6,7)));
skip
in interface org.jooq.lambda.Seq<T>
skip
in interface java.util.stream.Stream<T>
skip
in interface Traversable<T>
num
- Number of elemenets to skipReactiveSeq<T> skipWhile(java.util.function.Predicate<? super T> p)
assertThat(ReactiveSeq.of(4,3,6,7).sorted().skipWhile(i->i<6).toList(),equalTo(Arrays.asList(6,7)));
skipWhile
in interface org.jooq.lambda.Seq<T>
skipWhile
in interface Traversable<T>
p
- Predicate to skip while trueReactiveSeq<T> skipUntil(java.util.function.Predicate<? super T> p)
assertThat(ReactiveSeq.of(4,3,6,7).skipUntil(i->i==6).toList(),equalTo(Arrays.asList(6,7)));
skipUntil
in interface org.jooq.lambda.Seq<T>
skipUntil
in interface Traversable<T>
p
- Predicate to skip until truedefault ReactiveSeq<T> skipUntilClosed(java.util.function.Predicate<? super T> p)
skipUntilClosed
in interface org.jooq.lambda.Seq<T>
ReactiveSeq<T> limit(long num)
assertThat(ReactiveSeq.of(4,3,6,7).limit(2).toList(),equalTo(Arrays.asList(4,3));
limit
in interface org.jooq.lambda.Seq<T>
limit
in interface java.util.stream.Stream<T>
limit
in interface Traversable<T>
num
- Limit element size to numReactiveSeq<T> limitWhile(java.util.function.Predicate<? super T> p)
assertThat(ReactiveSeq.of(4,3,6,7).sorted().limitWhile(i->i<6).toList(),equalTo(Arrays.asList(3,4)));
limitWhile
in interface org.jooq.lambda.Seq<T>
limitWhile
in interface Traversable<T>
p
- Limit while predicate is trueReactiveSeq<T> limitUntil(java.util.function.Predicate<? super T> p)
assertThat(ReactiveSeq.of(4,3,6,7).limitUntil(i->i==6).toList(),equalTo(Arrays.asList(4,3)));
limitUntil
in interface org.jooq.lambda.Seq<T>
limitUntil
in interface Traversable<T>
p
- Limit until predicate is truedefault ReactiveSeq<T> limitUntilClosed(java.util.function.Predicate<? super T> p)
limitUntilClosed
in interface org.jooq.lambda.Seq<T>
ReactiveSeq<T> parallel()
boolean allMatch(java.util.function.Predicate<? super T> c)
assertThat(ReactiveSeq.of(1,2,3,4,5).allMatch(it-> it>0 && it <6),equalTo(true));
allMatch
in interface org.jooq.lambda.Collectable<T>
allMatch
in interface CyclopsCollectable<T>
allMatch
in interface java.util.stream.Stream<T>
c
- Predicate to check if all matchboolean anyMatch(java.util.function.Predicate<? super T> c)
assertThat(ReactiveSeq.of(1,2,3,4,5).anyMatch(it-> it.equals(3)),equalTo(true));
anyMatch
in interface org.jooq.lambda.Collectable<T>
anyMatch
in interface CyclopsCollectable<T>
anyMatch
in interface java.util.stream.Stream<T>
c
- Predicate to check if any matchboolean xMatch(int num, java.util.function.Predicate<? super T> c)
assertTrue(ReactiveSeq.of(1,2,3,5,6,7).xMatch(3, i-> i>4 ));
boolean noneMatch(java.util.function.Predicate<? super T> c)
noneMatch
in interface org.jooq.lambda.Collectable<T>
noneMatch
in interface CyclopsCollectable<T>
noneMatch
in interface java.util.stream.Stream<T>
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());
HeadAndTail<T> headAndTail()
{ @code 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 IterableFoldable<T>
java.util.Optional<T> findFirst()
java.util.Optional<T> findAny()
default <R> ReactiveSeq<R> trampoline(java.util.function.Function<? super T,? extends Trampoline<? extends R>> mapper)
ReactiveSeq.of(10,20,30,40)
.trampoline(i-> fibonacci(i))
.forEach(System.out::println);
Trampoline<Long> fibonacci(int i){
return fibonacci(i,1,0);
}
Trampoline<Long> fibonacci(int n, long a, long b) {
return n == 0 ? Trampoline.done(b) : Trampoline.more( ()->fibonacci(n-1, a+b, a));
}
55
6765
832040
102334155
ReactiveSeq.of(10_000,200_000,3_000_000,40_000_000)
.trampoline(i-> fibonacci(i))
.forEach(System.out::println);
completes successfully
trampoline
in interface Functor<T>
mapper
- <R> R mapReduce(Reducer<R> reducer)
ReactiveSeq.of("hello","2","world","4").mapReduce(Reducers.toCountInt());
//4
<R> R mapReduce(java.util.function.Function<? super T,? extends R> mapper, Monoid<R> reducer)
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;
}
T reduce(Monoid<T> reducer)
ReactiveSeq.of("hello","2","world","4").reduce(Reducers.toString(","));
//hello,2,world,4
<U> U reduce(U identity, java.util.function.BiFunction<U,? super T,U> accumulator, java.util.function.BinaryOperator<U> combiner)
ListX<T> reduce(java.util.stream.Stream<? extends Monoid<T>> reducers)
{ @code 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))); }
ListX<T> reduce(java.lang.Iterable<? extends Monoid<T>> reducers)
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)));
T foldRight(Monoid<T> reducer)
ReactiveSeq.of("a","b","c").foldRight(Reducers.toString(""));
// "cab"
T foldRight(T identity, java.util.function.BinaryOperator<T> accumulator)
assertTrue(ReactiveSeq.of("a","b","c").foldRight("", String::concat).equals("cba"));
<T> T foldRightMapToType(Reducer<T> reducer)
ReactiveSeq.of(1,2,3).foldRightMapToType(Reducers.toString(""));
// "321"
foldRightMapToType
in interface Foldable<T>
reducer
- Monoid to reduce valuesStreamable<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));
toStreamable
in interface ConvertableSequence<T>
java.util.Set<T> toSet()
toSet
in interface org.jooq.lambda.Collectable<T>
toSet
in interface CyclopsCollectable<T>
java.util.List<T> toList()
toList
in interface org.jooq.lambda.Collectable<T>
toList
in interface CyclopsCollectable<T>
<C extends java.util.Collection<T>> C toCollection(java.util.function.Supplier<C> collectionFactory)
toCollection
in interface org.jooq.lambda.Collectable<T>
toCollection
in interface CyclopsCollectable<T>
<T> java.util.stream.Stream<T> toStream()
ReactiveSeq<T> stream()
stream
in interface ConvertableSequence<T>
stream
in interface ExtendedTraversable<T>
stream
in interface Foldable<T>
stream
in interface IterableFunctor<T>
stream
in interface org.jooq.lambda.Seq<T>
stream
in interface TransformerTraversable<T>
stream
in interface Traversable<T>
boolean startsWithIterable(java.lang.Iterable<T> iterable)
assertTrue(ReactiveSeq.of(1,2,3,4).startsWith(Arrays.asList(1,2,3)));
startsWithIterable
in interface Foldable<T>
iterable
- boolean startsWith(java.util.stream.Stream<T> stream)
assertTrue(ReactiveSeq.of(1,2,3,4).startsWith(Stream.of(1,2,3)))
startsWith
in interface Foldable<T>
iterator
- <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 FilterableFunctor<T>
map
in interface Functor<T>
map
in interface IterableFunctor<T>
map
in interface org.jooq.lambda.Seq<T>
map
in interface java.util.stream.Stream<T>
fn
- Transformation functionReactiveSeq<T> peek(java.util.function.Consumer<? super T> c)
Functor
of(1,2,3).map(System.out::println)
1
2
3
<R> ReactiveSeq<R> flatMap(java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends R>> fn)
assertThat(ReactiveSeq.of(1,2)
.flatMap(i -> asList(i, -i).stream())
.toList(),equalTo(asList(1, -1, 2, -2)));
<R> ReactiveSeq<R> flatMapAnyM(java.util.function.Function<? super T,AnyM<? extends R>> fn)
assertThat(ReactiveSeq.of(1,2,3)).flatMapAnyM(i-> anyM(CompletableFuture.completedFuture(i+2))).toList(),equalTo(Arrays.asList(3,4,5)));
fn
- to be applied<R> ReactiveSeq<R> flatMapIterable(java.util.function.Function<? super T,? extends java.lang.Iterable<? extends R>> fn)
ReactiveSeq.of(1,2)
.flatMap(i -> asList(i, -i))
.toList();
//1,-1,2,-2
fn
- <R> ReactiveSeq<R> flatMapStream(java.util.function.Function<? super T,java.util.stream.BaseStream<? extends R,?>> fn)
assertThat(ReactiveSeq.of(1,2,3)
.flatMapStream(i->IntStream.of(i))
.toList(),equalTo(Arrays.asList(1,2,3)));
fn
- to be appliedReactiveSeq<T> filter(java.util.function.Predicate<? super T> fn)
Filterable
of(1,2,3).filter(i->i>2);
//[3]
filter
in interface Filterable<T>
filter
in interface FilterableFunctor<T>
filter
in interface JoolManipulation<T>
filter
in interface org.jooq.lambda.Seq<T>
filter
in interface java.util.stream.Stream<T>
fn
- to filter elements by, retaining matchesReactiveSeq<T> sequential()
ReactiveSeq<T> unordered()
ReactiveSeq<T> intersperse(T value)
intersperse
in interface org.jooq.lambda.Seq<T>
intersperse
in interface Traversable<T>
<U> ReactiveSeq<U> ofType(java.lang.Class<? extends U> type)
ofType
in interface Filterable<T>
ofType
in interface JoolManipulation<T>
ofType
in interface org.jooq.lambda.Seq<T>
<U> ReactiveSeq<U> cast(java.lang.Class<? extends U> type)
ClassCastException
.
// ClassCastException ReactiveSeq.of(1, "a", 2, "b", 3).cast(Integer.class)CollectionX<T> toLazyCollection()
{ @code 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 Foldable<T>
CollectionX<T> toConcurrentLazyCollection()
{ @code 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 Foldable<T>
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))); }
toConcurrentLazyStreamable
in interface Foldable<T>
ReactiveSeq<T> reverse()
reverse
in interface org.jooq.lambda.Seq<T>
reverse
in interface Traversable<T>
ReactiveSeq<T> onClose(java.lang.Runnable closeHandler)
ReactiveSeq<T> shuffle()
shuffle
in interface org.jooq.lambda.Seq<T>
shuffle
in interface Traversable<T>
ReactiveSeq<T> appendStream(java.util.stream.Stream<T> stream)
{ @code 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!!"))); }
stream
- to appendReactiveSeq<T> prependStream(java.util.stream.Stream<T> stream)
{ @code 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!!"))); }
stream
- to PrependReactiveSeq<T> append(T... values)
{ @code 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 org.jooq.lambda.Seq<T>
values
- to appendReactiveSeq<T> append(T value)
append
in interface org.jooq.lambda.Seq<T>
ReactiveSeq<T> prepend(T value)
prepend
in interface org.jooq.lambda.Seq<T>
ReactiveSeq<T> prepend(T... values)
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 org.jooq.lambda.Seq<T>
values
- to prependReactiveSeq<T> insertAt(int pos, T... values)
{ @code 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!!"))); }
pos
- to insert data atvalues
- to insertReactiveSeq<T> deleteBetween(int start, int end)
{ @code 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!!"))); }
start
- indexend
- indexReactiveSeq<T> insertStreamAt(int pos, java.util.stream.Stream<T> stream)
{ @code 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!!"))); }
pos
- to insert Stream atstream
- to insertFutureOperations<T> futureOperations(java.util.concurrent.Executor exec)
futureOperations
in interface Traversable<T>
exec
- Executor to use for Stream executionboolean endsWithIterable(java.lang.Iterable<T> iterable)
assertTrue(ReactiveSeq.of(1,2,3,4,5,6)
.endsWith(Arrays.asList(5,6)));
endsWithIterable
in interface Foldable<T>
iterable
- Values to checkboolean endsWith(java.util.stream.Stream<T> stream)
assertTrue(ReactiveSeq.of(1,2,3,4,5,6)
.endsWith(Stream.of(5,6)));
ReactiveSeq<T> skip(long time, java.util.concurrent.TimeUnit unit)
{ @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] }
time
- Length of timeunit
- Time unitReactiveSeq<T> limit(long time, java.util.concurrent.TimeUnit unit)
{ @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] }
time
- Length of timeunit
- Time unitReactiveSeq<T> skipLast(int num)
skipLast
in interface Traversable<T>
num
- ReactiveSeq<T> limitLast(int num)
assertThat(ReactiveSeq.of(1,2,3,4,5)
.limitLast(2)
.collect(Collectors.toList()),equalTo(Arrays.asList(4,5)));
limitLast
in interface Traversable<T>
num
- of elements to return (last elements)HotStream<T> hotStream(java.util.concurrent.Executor e)
primedHotStream(Executor)
.
The generated HotStream is not pausable, for a pausable HotStream @see 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
e
- Executor to execute this ReactiveSeq onHotStream<T> primedHotStream(java.util.concurrent.Executor e)
hotStream(Executor)
.
The generated HotStream is not pausable, for a pausable HotStream @see 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
e
- PausableHotStream<T> pausableHotStream(java.util.concurrent.Executor e)
primedPausableHotStream(Executor)
.
The generated HotStream is pausable, for a unpausable HotStream (slightly faster execution) @see 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
e
- Executor to execute this ReactiveSeq onPausableHotStream<T> primedPausableHotStream(java.util.concurrent.Executor e)
pausableHotStream(Executor)
.
The generated HotStream is pausable, for a unpausable HotStream @see 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
e
- T firstValue()
assertThat(ReactiveSeq.of(1,2,3,4)
.map(u->{throw new RuntimeException();})
.recover(e->"hello")
.firstValue(),equalTo("hello"));
firstValue
in interface Foldable<T>
default T single()
//1
ReactiveSeq.of(1).single();
//UnsupportedOperationException
ReactiveSeq.of().single();
//UnsupportedOperationException
ReactiveSeq.of(1,2,3).single();
default java.util.Optional<T> singleOptional()
//Optional[1]
ReactiveSeq.of(1).singleOptional();
//Optional.empty
ReactiveSeq.of().singleOpional();
//Optional.empty
ReactiveSeq.of(1,2,3).singleOptional();
singleOptional
in interface Foldable<T>
default java.util.Optional<T> get(long index)
assertThat(ReactiveSeq.of(1,2,3,4,5).elementAt(2).get(),equalTo(3));
default org.jooq.lambda.tuple.Tuple2<T,ReactiveSeq<T>> elementAt(long index)
ReactiveSeq.of(1,2,3,4,5).get(2).v1
//3
index
- to extract element fromdefault ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,java.lang.Long>> elapsed()
ReactiveSeq.of(1,2,3,4,5)
.elapsed()
.forEach(System.out::println);
default ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,java.lang.Long>> timestamp()
ReactiveSeq.of(1,2,3,4,5)
.timestamp()
.forEach(System.out::println)
static <T> SeqSubscriber<T> subscriber()
SeqSubscriber<Integer> sub = ReactiveSeq.subscriber();
ReactiveSeq.of(1,2,3).subscribe(sub);
sub.stream().forEach(System.out::println);
1
2
3
static <T> ReactiveSeq<T> empty()
@SafeVarargs static <T> ReactiveSeq<T> of(T... elements)
@SafeVarargs static <T> ReactiveSeq<T> reversedOf(T... elements)
elements
- To Construct sequence fromstatic <T> ReactiveSeq<T> reversedListOf(java.util.List<T> elements)
elements
- To Construct sequence fromstatic ReactiveSeq<java.lang.Integer> range(int start, int end)
range
in interface org.jooq.lambda.Seq<T>
start
- Number of range to start fromend
- Number for range to end atstatic ReactiveSeq<java.lang.Long> rangeLong(long start, long end)
start
- Number of range to start fromend
- Number for range to end atstatic <T> ReactiveSeq<T> fromStream(java.util.stream.Stream<T> stream)
stream
- Stream to construct Sequence fromstatic ReactiveSeq<java.lang.Integer> fromIntStream(java.util.stream.IntStream stream)
stream
- Stream to construct Sequence fromstatic ReactiveSeq<java.lang.Long> fromLongStream(java.util.stream.LongStream stream)
stream
- Stream to construct Sequence fromstatic ReactiveSeq<java.lang.Double> fromDoubleStream(java.util.stream.DoubleStream stream)
stream
- Stream to construct Sequence fromstatic <T> ReactiveSeq<T> fromList(java.util.List<T> list)
iterable
- to construct Sequence fromstatic <T> ReactiveSeq<T> fromPublisher(org.reactivestreams.Publisher<? extends T> publisher)
iterable
- to construct ReactiveSeq fromstatic <T> ReactiveSeq<T> fromIterable(java.lang.Iterable<T> iterable)
iterable
- to construct Sequence fromstatic <T> ReactiveSeq<T> fromIterator(java.util.Iterator<T> iterator)
iterator
- to construct Sequence fromstatic <T> ReactiveSeq<T> iterate(T seed, java.util.function.UnaryOperator<T> f)
static <U,T> ReactiveSeq<T> unfold(U seed, java.util.function.Function<? super U,java.util.Optional<org.jooq.lambda.tuple.Tuple2<T,U>>> unfolder)
ReactiveSeq.unfold(1,i->i<=6 ? Optional.of(Tuple.tuple(i,i+1)) : Optional.empty());
//(1,2,3,4,5)
unfold
in interface org.jooq.lambda.Seq<T>
seed
- Initial valueunfolder
- Iteratively applied function, terminated by an empty Optionalstatic <T> ReactiveSeq<T> generate(java.util.function.Supplier<T> s)
static <T,U> org.jooq.lambda.tuple.Tuple2<ReactiveSeq<T>,ReactiveSeq<U>> unzip(ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> sequence)
unzip(ReactiveSeq.of(new Tuple2(1, "a"), new Tuple2(2, "b"), new Tuple2(3, "c")))
// ReactiveSeq[1,2,3], ReactiveSeq[a,b,c]
static <T1,T2,T3> org.jooq.lambda.tuple.Tuple3<ReactiveSeq<T1>,ReactiveSeq<T2>,ReactiveSeq<T3>> unzip3(ReactiveSeq<org.jooq.lambda.tuple.Tuple3<T1,T2,T3>> sequence)
unzip3(ReactiveSeq.of(new Tuple3(1, "a", 2l), new Tuple3(2, "b", 3l), new Tuple3(3,"c", 4l)))
// ReactiveSeq[1,2,3], ReactiveSeq[a,b,c], ReactiveSeq[2l,3l,4l]
static <T1,T2,T3,T4> org.jooq.lambda.tuple.Tuple4<ReactiveSeq<T1>,ReactiveSeq<T2>,ReactiveSeq<T3>,ReactiveSeq<T4>> unzip4(ReactiveSeq<org.jooq.lambda.tuple.Tuple4<T1,T2,T3,T4>> sequence)
unzip4(ReactiveSeq.of(new Tuple4(1, "a", 2l,'z'), new Tuple4(2, "b", 3l,'y'), new Tuple4(3,
"c", 4l,'x')));
// ReactiveSeq[1,2,3], ReactiveSeq[a,b,c], ReactiveSeq[2l,3l,4l], ReactiveSeq[z,y,x]
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> crossJoin(java.util.stream.Stream<? extends U> other)
crossJoin
in interface org.jooq.lambda.Seq<T>
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> crossJoin(org.jooq.lambda.Seq<? extends U> other)
crossJoin
in interface org.jooq.lambda.Seq<T>
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> crossJoin(java.lang.Iterable<? extends U> other)
crossJoin
in interface org.jooq.lambda.Seq<T>
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> innerJoin(java.util.stream.Stream<? extends U> other, java.util.function.BiPredicate<? super T,? super U> predicate)
innerJoin
in interface org.jooq.lambda.Seq<T>
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> innerJoin(java.lang.Iterable<? extends U> other, java.util.function.BiPredicate<? super T,? super U> predicate)
innerJoin
in interface org.jooq.lambda.Seq<T>
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> innerJoin(org.jooq.lambda.Seq<? extends U> other, java.util.function.BiPredicate<? super T,? super U> predicate)
innerJoin
in interface org.jooq.lambda.Seq<T>
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> innerJoin(Streamable<? extends U> other, java.util.function.BiPredicate<? super T,? super U> predicate)
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> leftOuterJoin(java.util.stream.Stream<? extends U> other, java.util.function.BiPredicate<? super T,? super U> predicate)
leftOuterJoin
in interface org.jooq.lambda.Seq<T>
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> leftOuterJoin(org.jooq.lambda.Seq<? extends U> other, java.util.function.BiPredicate<? super T,? super U> predicate)
leftOuterJoin
in interface org.jooq.lambda.Seq<T>
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> leftOuterJoin(java.lang.Iterable<? extends U> other, java.util.function.BiPredicate<? super T,? super U> predicate)
leftOuterJoin
in interface org.jooq.lambda.Seq<T>
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> leftOuterJoin(Streamable<? extends U> s, java.util.function.BiPredicate<? super T,? super U> predicate)
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> rightOuterJoin(java.util.stream.Stream<? extends U> other, java.util.function.BiPredicate<? super T,? super U> predicate)
rightOuterJoin
in interface org.jooq.lambda.Seq<T>
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> rightOuterJoin(java.lang.Iterable<? extends U> other, java.util.function.BiPredicate<? super T,? super U> predicate)
rightOuterJoin
in interface org.jooq.lambda.Seq<T>
default <U> ReactiveSeq<org.jooq.lambda.tuple.Tuple2<T,U>> rightOuterJoin(org.jooq.lambda.Seq<? extends U> other, java.util.function.BiPredicate<? super T,? super U> predicate)
rightOuterJoin
in interface org.jooq.lambda.Seq<T>
default ReactiveSeq<T> onEmptySwitch(java.util.function.Supplier<? extends java.util.stream.Stream<T>> switchTo)
assertThat(ReactiveSeq.of(4,5,6)
.onEmptySwitch(()->ReactiveSeq.of(1,2,3))
.toList(),
equalTo(Arrays.asList(4,5,6)));
switchTo
- Supplier that will generate the alternative StreamReactiveSeq<T> onEmpty(T value)
onEmpty
in interface org.jooq.lambda.Seq<T>
onEmpty
in interface Traversable<T>
ReactiveSeq<T> onEmptyGet(java.util.function.Supplier<? extends T> supplier)
onEmptyGet
in interface org.jooq.lambda.Seq<T>
onEmptyGet
in interface Traversable<T>
default <X extends java.lang.Throwable> ReactiveSeq<T> onEmptyThrow(java.util.function.Supplier<? extends X> supplier)
onEmptyThrow
in interface org.jooq.lambda.Seq<T>
onEmptyThrow
in interface Traversable<T>
ReactiveSeq<T> concat(java.util.stream.Stream<? extends T> other)
concat
in interface org.jooq.lambda.Seq<T>
ReactiveSeq<T> concat(T other)
concat
in interface org.jooq.lambda.Seq<T>
ReactiveSeq<T> concat(T... other)
concat
in interface org.jooq.lambda.Seq<T>
<U> ReactiveSeq<T> distinct(java.util.function.Function<? super T,? extends U> keyExtractor)
distinct
in interface org.jooq.lambda.Seq<T>
ReactiveSeq<T> shuffle(java.util.Random random)
shuffle
in interface org.jooq.lambda.Seq<T>
shuffle
in interface Traversable<T>
ReactiveSeq<T> slice(long from, long to)
slice
in interface org.jooq.lambda.Seq<T>
slice
in interface Traversable<T>
<U extends java.lang.Comparable<? super U>> ReactiveSeq<T> sorted(java.util.function.Function<? super T,? extends U> function)
sorted
in interface org.jooq.lambda.Seq<T>
sorted
in interface Traversable<T>
ReactiveSeq<T> xPer(int x, long time, java.util.concurrent.TimeUnit t)
{ @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)); }
x
- number of elements to emittime
- periodt
- Time unitReactiveSeq<T> onePer(long time, java.util.concurrent.TimeUnit t)
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->{});
time
- periodt
- Time unitReactiveSeq<T> debounce(long time, java.util.concurrent.TimeUnit t)
ReactiveSeq.of(1,2,3,4,5,6)
.debounce(1000,TimeUnit.SECONDS).toList();
// 1
time
- t
- ReactiveSeq<T> fixedDelay(long l, java.util.concurrent.TimeUnit unit)
{ @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)); }
l
- time length in nanos of the delayunit
- for the delayReactiveSeq<T> jitter(long maxJitterPeriodInNanos)
{ @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)); }
maxJitterPeriodInNanos
- - random number less than this is used for each jitterReactiveSeq<T> recover(java.util.function.Function<java.lang.Throwable,? extends T> fn)
assertThat(ReactiveSeq.of(1,2,3,4)
.map(i->i+2)
.map(u->{throw new RuntimeException();})
.recover(e->"hello")
.firstValue(),equalTo("hello"));
fn
- Function that accepts a Throwable and returns an alternative
value<EX extends java.lang.Throwable> ReactiveSeq<T> recover(java.lang.Class<EX> exceptionClass, java.util.function.Function<EX,? extends T> fn)
assertThat(ReactiveSeq.of(1,2,3,4)
.map(i->i+2)
.map(u->{ExceptionSoftener.throwSoftenedException( new IOException()); return null;})
.recover(IOException.class,e->"hello")
.firstValue(),equalTo("hello"));
exceptionClass
- Type to recover fromfn
- That accepts an error and returns an alternative valuedefault <R> ReactiveSeq<R> retry(java.util.function.Function<? super T,? extends R> fn)
given(serviceMock.apply(anyInt())).willThrow(
new RuntimeException(new SocketException("First")),
new RuntimeException(new IOException("Second"))).willReturn(
"42");
String result = ReactiveSeq.of( 1, 2, 3)
.retry(serviceMock)
.firstValue();
//result = 42
fn
- Function to retry if failsdefault <R> ReactiveSeq<R> retry(java.util.function.Function<? super T,? extends R> fn, int retries, long delay, java.util.concurrent.TimeUnit timeUnit)
given(serviceMock.apply(anyInt())).willThrow(
new RuntimeException(new SocketException("First")),
new RuntimeException(new IOException("Second"))).willReturn(
"42");
String result = ReactiveSeq.of( 1, 2, 3)
.retry(serviceMock, 7, 2, TimeUnit.SECONDS)
.firstValue();
//result = 42
fn
- Function to retry if failsretries
- Number of retriesdelay
- Delay in TimeUnitsTimeUnit
- to use for delaydefault ReactiveSeq<T> remove(T t)
ReactiveSeq.of(1,2,3,4,5,1,2,3).remove(1)
//Streamable[2,3,4,5,2,3]
remove
in interface org.jooq.lambda.Seq<T>
t
- element to removedefault ReactiveSeq<ReactiveSeq<T>> permutations()
permutations
in interface ExtendedTraversable<T>
default ReactiveSeq<T> subStream(int start, int end)
ReactiveSeq.of(1,2,3,4,5,6).subStream(1,3);
//ReactiveSeq[2,3]
start
- index inclusiveend
- index exclusivedefault ReactiveSeq<ReactiveSeq<T>> combinations(int size)
ReactiveSeq.of(1,2,3).combinations(2)
//ReactiveSeq[ReactiveSeq[1,2],ReactiveSeq[1,3],ReactiveSeq[2,3]]
combinations
in interface ExtendedTraversable<T>
size
- of combinationsdefault ReactiveSeq<ReactiveSeq<T>> combinations()
ReactiveSeq.of(1,2,3).combinations()
//ReactiveSeq[ReactiveSeq[],ReactiveSeq[1],ReactiveSeq[2],ReactiveSeq[3].ReactiveSeq[1,2],ReactiveSeq[1,3],ReactiveSeq[2,3]
,ReactiveSeq[1,2,3]]
combinations
in interface ExtendedTraversable<T>
HotStream<T> schedule(java.lang.String cron, java.util.concurrent.ScheduledExecutorService ex)
//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
{ @code HotStream<Data> dataStream = ReactiveSeq.generate(() -> "next job:" + formatDate(new Date())).map(this::processJob) .schedule("0 20 * * *", Executors.newScheduledThreadPool(1)); data.connect().forEach(this::logToDB); }
HotStream<T> scheduleFixedDelay(long delay, java.util.concurrent.ScheduledExecutorService ex)
//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
{ @code 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 Foldable<T>
delay
- Between last element completes passing through the Stream
until the next one startsex
- ScheduledExecutorServiceHotStream<T> scheduleFixedRate(long rate, java.util.concurrent.ScheduledExecutorService ex)
//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
{ @code 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 Foldable<T>
rate
- Time in millis between job runsex
- ScheduledExecutorServicedefault int size()
<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);
//ReactiveSeq[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]
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 elements<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)
ReactiveSeq.of(1,2,3)
.forEach3(a->IntStream.range(10,13),
a->b->Stream.of(""+(a+b),"hello world"),
a->b->c-> c!=3,
a->b->c->c+":"a+":"+b);
//ReactiveSeq[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]
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 elements<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);
//ReactiveSeq[11,14,12,15,13,16]
stream1
- Nested Stream to iterate overyieldingFunction
- Function with pointers to the current element from both
Streams that generates the new elements<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);
//ReactiveSeq[14,15]
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 elementsdefault long count()
default <R,A> R collect(java.util.stream.Collector<? super T,A,R> collector)
collect
in interface org.jooq.lambda.Collectable<T>
collect
in interface CyclopsCollectable<T>
collect
in interface java.util.stream.Stream<T>
default org.jooq.lambda.Collectable<T> collectable()
CyclopsCollectable
collectable
in interface CyclopsCollectable<T>
collectable
in interface IterableFunctor<T>
default <R> ReactiveSeq<R> patternMatch(java.util.function.Function<Matchable.CheckValue1<T,R>,Matchable.CheckValue1<T,R>> case1, java.util.function.Supplier<? extends R> otherwise)
Functor
List<String> result = CollectionX.of(1,2,3,4)
.patternMatch(
c->c.valuesWhere(i->"even", (Integer i)->i%2==0 )
)
// CollectionX["odd","even","odd","even"]
patternMatch
in interface Functor<T>
case1
- Function to generate a case (or chain of cases as a single case)otherwise
- Value if supplied case doesn't matchdefault long count(java.util.function.Predicate<? super T> predicate)
count
in interface org.jooq.lambda.Collectable<T>
count
in interface CyclopsCollectable<T>
default long countDistinct(java.util.function.Predicate<? super T> predicate)
countDistinct
in interface org.jooq.lambda.Collectable<T>
countDistinct
in interface CyclopsCollectable<T>
default <U> long countDistinctBy(java.util.function.Function<? super T,? extends U> function, java.util.function.Predicate<? super U> predicate)
countDistinctBy
in interface org.jooq.lambda.Collectable<T>
countDistinctBy
in interface CyclopsCollectable<T>
default long countDistinct()
countDistinct
in interface org.jooq.lambda.Collectable<T>
countDistinct
in interface CyclopsCollectable<T>
default <U> long countDistinctBy(java.util.function.Function<? super T,? extends U> function)
countDistinctBy
in interface org.jooq.lambda.Collectable<T>
countDistinctBy
in interface CyclopsCollectable<T>
default java.util.Optional<T> mode()
mode
in interface org.jooq.lambda.Collectable<T>
mode
in interface CyclopsCollectable<T>
default java.util.Optional<T> sum()
sum
in interface org.jooq.lambda.Collectable<T>
sum
in interface CyclopsCollectable<T>
default <U> java.util.Optional<U> sum(java.util.function.Function<? super T,? extends U> function)
sum
in interface org.jooq.lambda.Collectable<T>
sum
in interface CyclopsCollectable<T>
default int sumInt(java.util.function.ToIntFunction<? super T> function)
sumInt
in interface org.jooq.lambda.Collectable<T>
sumInt
in interface CyclopsCollectable<T>
default long sumLong(java.util.function.ToLongFunction<? super T> function)
sumLong
in interface org.jooq.lambda.Collectable<T>
sumLong
in interface CyclopsCollectable<T>
default double sumDouble(java.util.function.ToDoubleFunction<? super T> function)
sumDouble
in interface org.jooq.lambda.Collectable<T>
sumDouble
in interface CyclopsCollectable<T>
default java.util.Optional<T> avg()
avg
in interface org.jooq.lambda.Collectable<T>
avg
in interface CyclopsCollectable<T>
default <U> java.util.Optional<U> avg(java.util.function.Function<? super T,? extends U> function)
avg
in interface org.jooq.lambda.Collectable<T>
avg
in interface CyclopsCollectable<T>
default double avgInt(java.util.function.ToIntFunction<? super T> function)
avgInt
in interface org.jooq.lambda.Collectable<T>
avgInt
in interface CyclopsCollectable<T>
default double avgLong(java.util.function.ToLongFunction<? super T> function)
avgLong
in interface org.jooq.lambda.Collectable<T>
avgLong
in interface CyclopsCollectable<T>
default double avgDouble(java.util.function.ToDoubleFunction<? super T> function)
avgDouble
in interface org.jooq.lambda.Collectable<T>
avgDouble
in interface CyclopsCollectable<T>
default java.util.Optional<T> min()
min
in interface org.jooq.lambda.Collectable<T>
min
in interface CyclopsCollectable<T>
default <U extends java.lang.Comparable<? super U>> java.util.Optional<U> min(java.util.function.Function<? super T,? extends U> function)
min
in interface org.jooq.lambda.Collectable<T>
min
in interface CyclopsCollectable<T>
default <U> java.util.Optional<U> min(java.util.function.Function<? super T,? extends U> function, java.util.Comparator<? super U> comparator)
min
in interface org.jooq.lambda.Collectable<T>
min
in interface CyclopsCollectable<T>
default <U extends java.lang.Comparable<? super U>> java.util.Optional<T> minBy(java.util.function.Function<? super T,? extends U> function)
minBy
in interface org.jooq.lambda.Collectable<T>
minBy
in interface CyclopsCollectable<T>
default <U> java.util.Optional<T> minBy(java.util.function.Function<? super T,? extends U> function, java.util.Comparator<? super U> comparator)
minBy
in interface org.jooq.lambda.Collectable<T>
minBy
in interface CyclopsCollectable<T>
default java.util.Optional<T> max()
max
in interface org.jooq.lambda.Collectable<T>
max
in interface CyclopsCollectable<T>
default <U extends java.lang.Comparable<? super U>> java.util.Optional<U> max(java.util.function.Function<? super T,? extends U> function)
max
in interface org.jooq.lambda.Collectable<T>
max
in interface CyclopsCollectable<T>
default <U> java.util.Optional<U> max(java.util.function.Function<? super T,? extends U> function, java.util.Comparator<? super U> comparator)
max
in interface org.jooq.lambda.Collectable<T>
max
in interface CyclopsCollectable<T>
default <U extends java.lang.Comparable<? super U>> java.util.Optional<T> maxBy(java.util.function.Function<? super T,? extends U> function)
maxBy
in interface org.jooq.lambda.Collectable<T>
maxBy
in interface CyclopsCollectable<T>
default <U> java.util.Optional<T> maxBy(java.util.function.Function<? super T,? extends U> function, java.util.Comparator<? super U> comparator)
maxBy
in interface org.jooq.lambda.Collectable<T>
maxBy
in interface CyclopsCollectable<T>
default java.util.Optional<T> median()
median
in interface org.jooq.lambda.Collectable<T>
median
in interface CyclopsCollectable<T>
default java.util.Optional<T> median(java.util.Comparator<? super T> comparator)
median
in interface org.jooq.lambda.Collectable<T>
median
in interface CyclopsCollectable<T>
default <U extends java.lang.Comparable<? super U>> java.util.Optional<T> medianBy(java.util.function.Function<? super T,? extends U> function)
medianBy
in interface org.jooq.lambda.Collectable<T>
medianBy
in interface CyclopsCollectable<T>
default <U> java.util.Optional<T> medianBy(java.util.function.Function<? super T,? extends U> function, java.util.Comparator<? super U> comparator)
medianBy
in interface org.jooq.lambda.Collectable<T>
medianBy
in interface CyclopsCollectable<T>
default java.util.Optional<T> percentile(double percentile)
percentile
in interface org.jooq.lambda.Collectable<T>
percentile
in interface CyclopsCollectable<T>
default java.util.Optional<T> percentile(double percentile, java.util.Comparator<? super T> comparator)
percentile
in interface org.jooq.lambda.Collectable<T>
percentile
in interface CyclopsCollectable<T>
default <U extends java.lang.Comparable<? super U>> java.util.Optional<T> percentileBy(double percentile, java.util.function.Function<? super T,? extends U> function)
percentileBy
in interface org.jooq.lambda.Collectable<T>
percentileBy
in interface CyclopsCollectable<T>
default <U> java.util.Optional<T> percentileBy(double percentile, java.util.function.Function<? super T,? extends U> function, java.util.Comparator<? super U> comparator)
percentileBy
in interface org.jooq.lambda.Collectable<T>
percentileBy
in interface CyclopsCollectable<T>
default <L extends java.util.List<T>> L toList(java.util.function.Supplier<L> factory)
toList
in interface org.jooq.lambda.Collectable<T>
toList
in interface CyclopsCollectable<T>
default <S extends java.util.Set<T>> S toSet(java.util.function.Supplier<S> factory)
toSet
in interface org.jooq.lambda.Collectable<T>
toSet
in interface CyclopsCollectable<T>
default <K,V> java.util.Map<K,V> toMap(java.util.function.Function<? super T,? extends K> keyMapper, java.util.function.Function<? super T,? extends V> valueMapper)
toMap
in interface org.jooq.lambda.Collectable<T>
toMap
in interface CyclopsCollectable<T>
default java.lang.String toString(java.lang.CharSequence delimiter)
toString
in interface org.jooq.lambda.Collectable<T>
toString
in interface CyclopsCollectable<T>
default java.lang.String toString(java.lang.CharSequence delimiter, java.lang.CharSequence prefix, java.lang.CharSequence suffix)
toString
in interface org.jooq.lambda.Collectable<T>
toString
in interface CyclopsCollectable<T>
default java.util.Optional<T> max(java.util.Comparator<? super T> comparator)
max
in interface org.jooq.lambda.Collectable<T>
max
in interface CyclopsCollectable<T>
max
in interface java.util.stream.Stream<T>
default java.util.Optional<T> min(java.util.Comparator<? super T> comparator)
min
in interface org.jooq.lambda.Collectable<T>
min
in interface CyclopsCollectable<T>
min
in interface java.util.stream.Stream<T>
default void printErr()
default void print(java.io.PrintWriter writer)