public interface FutureStream<U> extends org.jooq.lambda.Seq<U>, ConfigurableStream<U>, BlockingStream<U>, SimpleReactStream<U>, ToQueue<U>
Modifier and Type | Interface and Description |
---|---|
static class |
FutureStream.Val<T> |
java.util.stream.Stream.Builder<T>
ConfigurableStream.SimpleReactConfigurableStream<U>
Modifier and Type | Field and Description |
---|---|
static ExceptionSoftener |
softener |
Modifier and Type | Method and Description |
---|---|
default boolean |
allMatch(java.util.function.Predicate<? super U> predicate) |
default <T,R> FutureStream<R> |
allOf(java.util.stream.Collector collector,
java.util.function.Function<T,R> fn) |
default <T,R> FutureStream<R> |
allOf(java.util.function.Function<java.util.List<T>,R> fn)
React and allOf
allOf is a non-blocking equivalent of block.
|
default boolean |
anyMatch(java.util.function.Predicate<? super U> predicate) |
default <R> FutureStream<R> |
anyOf(java.util.function.Function<U,R> fn)
React to the completion of any of the events in the previous stage.
|
default FutureStream<U> |
async() |
default FutureStream<java.util.Collection<U>> |
batch(java.util.function.Function<java.util.function.Supplier<U>,java.util.function.Supplier<java.util.Collection<U>>> fn)
Batch elements into a Stream of collections with user defined function
|
default FutureStream<java.util.Collection<U>> |
batchBySize(int size)
Batch the elements in this stream into Lists of specified size
|
default FutureStream<java.util.Collection<U>> |
batchBySize(int size,
java.util.function.Supplier<java.util.Collection<U>> supplier)
Batch the elements in this stream into Collections of specified size
The type of Collection is determined by the specified supplier
|
default FutureStream<java.util.Collection<U>> |
batchByTime(long time,
java.util.concurrent.TimeUnit unit)
Organise elements in a Stream into a Collections based on the time period they pass through this stage
|
default FutureStream<java.util.Collection<U>> |
batchByTime(long time,
java.util.concurrent.TimeUnit unit,
java.util.function.Supplier<java.util.Collection<U>> factory)
Organise elements in a Stream into a Collections based on the time period they pass through this stage
|
default void |
cancel()
Cancel the CompletableFutures in this stage of the stream
|
default FutureStream<U> |
capture(java.util.function.Consumer<? extends java.lang.Throwable> errorHandler)
React capture
While onFail is used for disaster recovery (when it is possible to
recover) - capture is used to capture those occasions where the full
pipeline has failed and is unrecoverable.
|
default <U> FutureStream<U> |
cast(java.lang.Class<U> type) |
static <T,U> FutureStream<U> |
cast(FutureStream<T> stream,
java.lang.Class<U> type)
Cast all elements in a stream to a given type, possibly throwing a
ClassCastException . |
default java.util.Iterator<java.util.Collection<U>> |
chunkLastReadIterator() |
default FutureStream<java.util.Collection<U>> |
chunkSinceLastRead() |
default void |
close() |
static void |
closeOthers(FutureStream active,
java.util.List<FutureStream> all)
Close all streams except the active one
|
static void |
closeOthers(Queue active,
java.util.List<Queue> all)
Close all queues except the active one
|
default <R> R |
collect(java.util.function.Supplier<R> supplier,
java.util.function.BiConsumer<R,? super U> accumulator,
java.util.function.BiConsumer<R,R> combiner) |
default <T> FutureStream<org.jooq.lambda.tuple.Tuple2<U,T>> |
combineLatest(FutureStream<T> s)
Similar to zip and withLatest, except will always take the latest from either Stream (merged with last available from the other).
|
static <T1,T2> org.jooq.lambda.Seq<org.jooq.lambda.tuple.Tuple2<T1,T2>> |
combineLatest(FutureStream<T1> left,
FutureStream<T2> right)
Zip two streams into one.
|
static <T1,T2,R> org.jooq.lambda.Seq<R> |
combineLatest(FutureStream<T1> left,
FutureStream<T2> right,
java.util.function.BiFunction<T1,T2,R> zipper)
Zip two streams into one using a
BiFunction to produce resulting. |
default FutureStream<U> |
control(java.util.function.Function<java.util.function.Supplier<U>,java.util.function.Supplier<U>> fn)
Allows clients to control the emission of data for the next phase of the Stream.
|
default long |
count() |
default FutureStream<U> |
debounce(long time,
java.util.concurrent.TimeUnit unit)
Can be used to debounce (accept a single data point from a unit of time) data.
|
default FutureStream<U> |
filter(java.util.function.Predicate<? super U> p)
Removes elements that do not match the supplied predicate from the
dataflow
|
default java.util.Optional<U> |
findAny() |
default java.util.Optional<U> |
findFirst() |
static <U> FutureStream<U> |
firstOf(FutureStream<U>... futureStreams)
Return first Stream out of provided Streams that starts emitted results
|
default FutureStream<U> |
fixedDelay(long time,
java.util.concurrent.TimeUnit unit)
Apply a fixed delay before emitting elements to the next phase of the Stream.
|
default <R> FutureStream<R> |
flatMap(java.util.function.Function<? super U,? extends java.util.stream.Stream<? extends R>> flatFn)
Allows aggregate values in a Stream to be flatten into a single Stream.
|
default java.util.stream.DoubleStream |
flatMapToDouble(java.util.function.Function<? super U,? extends java.util.stream.DoubleStream> mapper) |
default java.util.stream.IntStream |
flatMapToInt(java.util.function.Function<? super U,? extends java.util.stream.IntStream> mapper) |
default java.util.stream.LongStream |
flatMapToLong(java.util.function.Function<? super U,? extends java.util.stream.LongStream> mapper) |
default void |
forEach(java.util.function.Consumer<? super U> action)
Stream supporting methods
|
default void |
forEachOrdered(java.util.function.Consumer<? super U> action) |
default <R> FutureStream<R> |
fromStream(java.util.stream.Stream<R> stream) |
default <R> FutureStream<R> |
fromStreamOfFutures(java.util.stream.Stream<java.util.concurrent.CompletableFuture<R>> stream)
Construct a SimpleReactStream from provided Stream of CompletableFutures
|
static <T> FutureStream<T> |
intersperse(FutureStream<T> stream,
T value)
Returns a stream with a given value interspersed between any two values
of this stream.
|
default FutureStream<U> |
intersperse(U value)
Returns a stream with a given value interspersed between any two values
of this stream.
|
default boolean |
isParallel() |
default CloseableIterator<U> |
iterator() |
default FutureStream<U> |
jitter(long jitterInNanos)
Introduce a random delay between events in a stream
Can be used to prevent behaviour synchronizing within a system
|
static <T,R> java.util.function.Function<FutureStream<T>,FutureStream<R>> |
lift(java.util.function.Function<T,R> fn) |
static <T1,T2,R> java.util.function.BiFunction<FutureStream<T1>,FutureStream<T2>,FutureStream<R>> |
lift2(java.util.function.BiFunction<T1,T2,R> fn) |
default <R> FutureStream<R> |
map(java.util.function.Function<? super U,? extends R> mapper) |
default java.util.stream.DoubleStream |
mapToDouble(java.util.function.ToDoubleFunction<? super U> mapper) |
default java.util.stream.IntStream |
mapToInt(java.util.function.ToIntFunction<? super U> mapper) |
default java.util.stream.LongStream |
mapToLong(java.util.function.ToLongFunction<? super U> mapper) |
default java.util.Optional<U> |
max(java.util.Comparator<? super U> comparator) |
static <R> FutureStream<R> |
merge(FutureStream s1,
FutureStream s2)
Merge this reactive dataflow with another - recommended for merging
different types.
|
default FutureStream<U> |
merge(SimpleReactStream<U> s)
Merge this reactive dataflow with another of the same type.
|
default java.util.Optional<U> |
min(java.util.Comparator<? super U> comparator) |
default boolean |
noneMatch(java.util.function.Predicate<? super U> predicate) |
default <U> FutureStream<U> |
ofType(java.lang.Class<U> type) |
static <T,U> FutureStream<U> |
ofType(FutureStream<T> stream,
java.lang.Class<U> type)
Keep only those elements in a stream that are of a given type.
|
default org.jooq.lambda.Seq<U> |
onClose(java.lang.Runnable closeHandler) |
default FutureStream<U> |
onePer(long time,
java.util.concurrent.TimeUnit unit)
Slow emissions down, emiting one element per specified time period
|
default FutureStream<U> |
onFail(java.lang.Class<? extends java.lang.Throwable> exceptionClass,
java.util.function.Function<? extends SimpleReactFailedStageException,U> fn)
Recover for a particular class of exceptions only.
|
default FutureStream<U> |
onFail(java.util.function.Function<? extends SimpleReactFailedStageException,U> fn)
React onFail
Define a function that can be used to recover from exceptions during the
preceeding stage of the dataflow.
|
default FutureStream<U> |
peek(java.util.function.Consumer<? super U> consumer)
Peek asynchronously at the results in the current stage.
|
default java.util.Optional<U> |
reduce(java.util.function.BinaryOperator<U> accumulator) |
default <R> R |
reduce(R identity,
java.util.function.BiFunction<R,? super U,R> accumulator,
java.util.function.BinaryOperator<R> combiner) |
default U |
reduce(U identity,
java.util.function.BinaryOperator<U> accumulator) |
default <R> FutureStream<R> |
retry(java.util.function.Function<U,R> fn)
Will execute this phase on the RetryExecutor (default or user supplied).
|
default FutureStream<U> |
reverse() |
default java.util.Iterator<U> |
reversedIterator() |
default FutureStream<U> |
self(java.util.function.Consumer<FutureStream<U>> consumer)
Give a function access to the current stage of a SimpleReact Stream
|
default org.jooq.lambda.Seq<U> |
sequential() |
default <K> java.util.Map<K,? extends FutureStream<U>> |
shard(java.util.Map<K,Queue<U>> shards,
java.util.function.Function<U,K> sharder)
Break a stream into multiple Streams based of some characteristic of the elements of the Stream
e.g.
|
default <T> FutureStream<U> |
skipUntil(FutureStream<T> s)
Return a Stream with the same values as this Stream, but with all values omitted until the provided stream starts emitting values.
|
static <T1,T2> org.jooq.lambda.Seq<T1> |
skipUntil(FutureStream<T1> left,
FutureStream<T2> right) |
static <T> org.jooq.lambda.Seq<T> |
slice(FutureStream<T> stream,
long from,
long to)
Returns a limited interval from a given Stream.
|
default org.jooq.lambda.Seq<U> |
slice(long from,
long to)
Returns a limited interval from a given Stream.
|
default org.jooq.lambda.Seq<U> |
sorted() |
default org.jooq.lambda.Seq<U> |
sorted(java.util.Comparator<? super U> comparator) |
default java.util.Spliterator<U> |
spliterator() |
default java.util.stream.Stream<U> |
stream() |
default FutureStream<U> |
sync() |
default <T> FutureStream<U> |
takeUntil(FutureStream<T> s)
Return a Stream with the same values, but will stop emitting values once the provided Stream starts to emit values.
|
static <T1,T2> org.jooq.lambda.Seq<T1> |
takeUntil(FutureStream<T1> left,
FutureStream<T2> right) |
default <R> FutureStream<R> |
then(java.util.function.Function<U,R> fn)
React then
Unlike 'with' this method is fluent, and returns another Stage Builder
that can represent the next stage in the dataflow.
|
default java.lang.Object[] |
toArray() |
default <A> A[] |
toArray(java.util.function.IntFunction<A[]> generator) |
default FutureStream<U> |
unordered() |
default <T> FutureStream<org.jooq.lambda.tuple.Tuple2<U,T>> |
withLatest(FutureStream<T> s)
Similar to zip and combineLatest, except will always take the latest from this Stream while taking the last available value from the provided stream.
|
static <T1,T2> org.jooq.lambda.Seq<org.jooq.lambda.tuple.Tuple2<T1,T2>> |
withLatest(FutureStream<T1> left,
FutureStream<T2> right)
Zip two streams into one.
|
static <T1,T2,R> org.jooq.lambda.Seq<R> |
withLatest(FutureStream<T1> left,
FutureStream<T2> right,
java.util.function.BiFunction<T1,T2,R> zipper)
Zip two streams into one using a
BiFunction to produce resulting. |
default FutureStream<U> |
xPer(int x,
long time,
java.util.concurrent.TimeUnit unit)
Allows x (specified number of) emissions with a time period before stopping emmissions until specified time has elapsed since last emission
|
default <R> FutureStream<org.jooq.lambda.tuple.Tuple2<U,R>> |
zipFutures(FutureStream<R> other)
Zip two Streams, zipping against the underlying futures of both Streams
Placeholders (Futures) will be populated immediately in the new zipped Stream and results
will be populated asyncrhonously
|
default <R> FutureStream<org.jooq.lambda.tuple.Tuple2<U,R>> |
zipFutures(java.util.stream.Stream<R> other)
Zip two Streams, zipping against the underlying futures of this stream
|
cast, concat, concat, concat, concat, cycle, cycle, distinct, duplicate, duplicate, empty, foldLeft, foldLeft, foldRight, foldRight, generate, generate, generate, groupBy, groupBy, groupBy, groupBy, groupBy, groupBy, intersperse, iterate, join, join, join, join, join, join, limit, limit, limitUntil, limitUntil, limitWhile, limitWhile, maxBy, maxBy, minBy, minBy, of, of, ofType, parallel, partition, partition, reverse, scanLeft, scanLeft, scanRight, scanRight, seq, seq, seq, seq, seq, shuffle, shuffle, shuffle, shuffle, skip, skip, skipUntil, skipUntil, skipWhile, skipWhile, slice, splitAt, splitAt, splitAtHead, splitAtHead, toCollection, toCollection, toList, toList, toMap, toMap, toMap, toSet, toSet, toString, toString, toString, unfold, unzip, unzip, unzip, unzip, zip, zip, zip, zip, zipWithIndex, zipWithIndex
assureSimpleReactException, bind, doOnEach, doOnEachSync, empty, filterSync, fromListCompletableFuture, fromStreamCompletableFutureReplace, getOriginalFutures, getSubscription, handleExceptions, join, lastActiveArray, merge, of, of, of, of, ofIterable, parallelBuilder, parallelBuilder, parallelCommonBuilder, parallelOf, peekSync, react, react, sequentialBuilder, sequentialCommonBuilder, streamCompletableFutures, then, thenSync, with
block, block, block, block, blockAndExtract, blockAndExtract, first, last
withAsync, withErrorHandler, withLastActive, withLazyCollector, withQueueFactory, withRetrier, withSubscription, withTaskExecutor, withWaitStrategy
getErrorHandler, getLastActive, getRetrier, getSimpleReact, getTaskExecutor, isAsync, isEager
getQueueFactory, toQueue, toQueue, toQueue
static final ExceptionSoftener softener
static <T,R> java.util.function.Function<FutureStream<T>,FutureStream<R>> lift(java.util.function.Function<T,R> fn)
static <T1,T2,R> java.util.function.BiFunction<FutureStream<T1>,FutureStream<T2>,FutureStream<R>> lift2(java.util.function.BiFunction<T1,T2,R> fn)
default <R> FutureStream<org.jooq.lambda.tuple.Tuple2<U,R>> zipFutures(java.util.stream.Stream<R> other)
other
- default <R> FutureStream<org.jooq.lambda.tuple.Tuple2<U,R>> zipFutures(FutureStream<R> other)
other
- Another FutureStream to zip Futures withdefault java.util.Iterator<java.util.Collection<U>> chunkLastReadIterator()
default FutureStream<java.util.Collection<U>> chunkSinceLastRead()
default <K> java.util.Map<K,? extends FutureStream<U>> shard(java.util.Map<K,Queue<U>> shards, java.util.function.Function<U,K> sharder)
shards
- Map of Queue's keyed by shard identifiersharder
- Function to split split incoming elements into shardsdefault void cancel()
default FutureStream<java.util.Collection<U>> batchBySize(int size)
size
- Size of lists elements should be batched intodefault FutureStream<java.util.Collection<U>> batch(java.util.function.Function<java.util.function.Supplier<U>,java.util.function.Supplier<java.util.Collection<U>>> fn)
fn
- Function takes a supplier, which can be used repeatedly to get the next value from the Stream. If there are no more values, a ClosedQueueException will be thrown.
This function should return a Supplier which creates a collection of the batched valuesdefault FutureStream<java.util.Collection<U>> batchBySize(int size, java.util.function.Supplier<java.util.Collection<U>> supplier)
size
- Size of batchsupplier
- Create the batch holding collectiondefault FutureStream<U> jitter(long jitterInNanos)
jitterInNanos
- Max number of nanos for jitter (random number less than this will be selected)/default FutureStream<U> fixedDelay(long time, java.util.concurrent.TimeUnit unit)
time
- amount of time between emissionsunit
- TimeUnit for emissionsdefault FutureStream<U> control(java.util.function.Function<java.util.function.Supplier<U>,java.util.function.Supplier<U>> fn)
fn
- Function takes a supplier, which can be used repeatedly to get the next value from the Stream. If there are no more values, a ClosedQueueException will be thrown.
This function should return a Supplier which returns the desired result for the next element (or just the next element).default FutureStream<U> debounce(long time, java.util.concurrent.TimeUnit unit)
time
- Time from which to accept only one elementunit
- Time unit for specified timedefault FutureStream<U> onePer(long time, java.util.concurrent.TimeUnit unit)
time
- Frequency period of element emissionunit
- Time unit for frequency perioddefault FutureStream<U> xPer(int x, long time, java.util.concurrent.TimeUnit unit)
x
- Number of allowable emissions per time periodtime
- Frequency time periodunit
- Frequency time unitdefault FutureStream<java.util.Collection<U>> batchByTime(long time, java.util.concurrent.TimeUnit unit)
time
- Time period during which all elements should be collectedunit
- Time unit during which all elements should be collecteddefault FutureStream<java.util.Collection<U>> batchByTime(long time, java.util.concurrent.TimeUnit unit, java.util.function.Supplier<java.util.Collection<U>> factory)
time
- Time period during which all elements should be collectedunit
- Time unit during which all elements should be collectedfactory
- Instantiates the collections used in the batchingdefault <T> FutureStream<org.jooq.lambda.tuple.Tuple2<U,T>> withLatest(FutureStream<T> s)
s
- Stream to merge withdefault <T> FutureStream<org.jooq.lambda.tuple.Tuple2<U,T>> combineLatest(FutureStream<T> s)
s
- Stream to merge withdefault <T> FutureStream<U> skipUntil(FutureStream<T> s)
s
- Stream that will start the emission of values from this streamdefault <T> FutureStream<U> takeUntil(FutureStream<T> s)
s
- Stream that will stop the emission of values from this streamstatic void closeOthers(Queue active, java.util.List<Queue> all)
active
- Queue not to closeall
- All queues potentially including the active queuestatic void closeOthers(FutureStream active, java.util.List<FutureStream> all)
active
- Stream not to closeall
- All streams potentially including the active streamstatic <U> FutureStream<U> firstOf(FutureStream<U>... futureStreams)
futureStreams
- Streams to racestatic <T1,T2> org.jooq.lambda.Seq<org.jooq.lambda.tuple.Tuple2<T1,T2>> combineLatest(FutureStream<T1> left, FutureStream<T2> right)
static <T1,T2,R> org.jooq.lambda.Seq<R> combineLatest(FutureStream<T1> left, FutureStream<T2> right, java.util.function.BiFunction<T1,T2,R> zipper)
BiFunction
to produce resulting.
values. Uses the latest values from each rather than waiting for both.static <T1,T2> org.jooq.lambda.Seq<org.jooq.lambda.tuple.Tuple2<T1,T2>> withLatest(FutureStream<T1> left, FutureStream<T2> right)
static <T1,T2,R> org.jooq.lambda.Seq<R> withLatest(FutureStream<T1> left, FutureStream<T2> right, java.util.function.BiFunction<T1,T2,R> zipper)
BiFunction
to produce resulting.
values. Uses the latest values from each rather than waiting for both.static <T1,T2> org.jooq.lambda.Seq<T1> skipUntil(FutureStream<T1> left, FutureStream<T2> right)
static <T1,T2> org.jooq.lambda.Seq<T1> takeUntil(FutureStream<T1> left, FutureStream<T2> right)
default <R> FutureStream<R> retry(java.util.function.Function<U,R> fn)
SimpleReactStream
retry
in interface SimpleReactStream<U>
fn
- Function that will be executed and retried on failuredefault <T,R> FutureStream<R> allOf(java.util.stream.Collector collector, java.util.function.Function<T,R> fn)
allOf
in interface SimpleReactStream<U>
collector
- to perform aggregation / reduction operation on the results
from active stage (e.g. to Collect into a List or String)fn
- Function that receives the results of all currently active
tasks as inputdefault <R> FutureStream<R> anyOf(java.util.function.Function<U,R> fn)
SimpleReactStream
anyOf
in interface SimpleReactStream<U>
fn
- Function to apply when any of the previous events completedefault <R> FutureStream<R> fromStreamOfFutures(java.util.stream.Stream<java.util.concurrent.CompletableFuture<R>> stream)
SimpleReactStream
fromStreamOfFutures
in interface SimpleReactStream<U>
stream
- JDK Stream to construct new SimpleReactStream fromdefault <R> FutureStream<R> then(java.util.function.Function<U,R> fn)
SimpleReactStream
new SimpleReact().<Integer, Integer> react(() -> 1, () -> 2, () -> 3)
.then((it) -> it * 100)
.then((it) -> "*" + it)
React then allows event reactors to be chained. Unlike React with, which
returns a collection of Future references, React then is a fluent
interface that returns the React builder - allowing further reactors to
be added to the chain.
React then does not block.
React with can be called after React then which gives access to the full
CompleteableFuture api. CompleteableFutures can be passed back into
SimpleReact via SimpleReact.react(streamOfCompleteableFutures);
See this blog post for examples of what can be achieved via
CompleteableFuture :- http://www.nurkiewicz.com/2013/12/promises-and-completablefuture.htm
l then
in interface SimpleReactStream<U>
fn
- Function to be applied to the results of the currently active
event tasksdefault <R> FutureStream<R> fromStream(java.util.stream.Stream<R> stream)
fromStream
in interface SimpleReactStream<U>
default <R> FutureStream<R> flatMap(java.util.function.Function<? super U,? extends java.util.stream.Stream<? extends R>> flatFn)
SimpleReactStream
flatMap
in interface org.jooq.lambda.Seq<U>
flatMap
in interface SimpleReactStream<U>
flatMap
in interface java.util.stream.Stream<U>
flatFn
- Function that coverts a value (e.g. a Collection) into a Streamdefault FutureStream<U> merge(SimpleReactStream<U> s)
SimpleReactStream
merge
in interface SimpleReactStream<U>
s
- Reactive stage builder to merge withdefault FutureStream<U> onFail(java.util.function.Function<? extends SimpleReactFailedStageException,U> fn)
SimpleReactStream
List<String> strings = new SimpleReact().<Integer, Integer> react(() -> 100, () -> 2, () -> 3)
.then(it -> {
if (it == 100)
throw new RuntimeException("boo!");
return it;
})
.onFail(e -> 1)
.then(it -> "*" + it)
.block();
In this example onFail recovers from the RuntimeException thrown when the
input to the first 'then' stage is 100.onFail
in interface SimpleReactStream<U>
fn
- Recovery function, the exception is input, and the recovery
value is outputdefault FutureStream<U> onFail(java.lang.Class<? extends java.lang.Throwable> exceptionClass, java.util.function.Function<? extends SimpleReactFailedStageException,U> fn)
SimpleReactStream
onFail(IOException.class, recoveryFunction1)
.onFail(Throwable.class,recovertyFunction2)
For an IOException recoveryFunction1 will be executed
but with the definitions reveresed
onFail(Throwable.class,recovertyFunction2)
.onFail(IOException.class, recoveryFunction1)
recoveryFunction1 will not be calledonFail
in interface SimpleReactStream<U>
exceptionClass
- Class of exceptions to recover fromfn
- Recovery functiondefault FutureStream<U> capture(java.util.function.Consumer<? extends java.lang.Throwable> errorHandler)
SimpleReactStream
List<String> strings = new SimpleReact().<Integer, Integer> react(() -> 1, () -> 2, () -> 3)
.then(it -> it * 100)
.then(it -> {
if (it == 100)
throw new RuntimeException("boo!");
return it;
})
.onFail(e -> 1)
.then(it -> "*" + it)
.then(it -> {
if ("*200".equals(it))
throw new RuntimeException("boo!");
return it;
})
.capture(e -> logger.error(e.getMessage(),e))
.block();
In this case, strings will only contain the two successful results (for
()->1 and ()->3), an exception for the chain starting from Supplier
()->2 will be logged by capture. Capture will not capture the
exception thrown when an Integer value of 100 is found, but will catch
the exception when the String value "*200" is passed along the chain.capture
in interface SimpleReactStream<U>
errorHandler
- A consumer that recieves and deals with an unrecoverable error
in the dataflowdefault <T,R> FutureStream<R> allOf(java.util.function.Function<java.util.List<T>,R> fn)
SimpleReactStream
boolean blocked[] = {false};
new SimpleReact().<Integer, Integer> react(() -> 1, () -> 2, () -> 3)
.then(it -> {
try {
Thread.sleep(50000);
} catch (Exception e) {
}
blocked[0] =true;
return 10;
})
.allOf( it -> it.size());
assertThat(blocked[0],is(false));
In this example, the current thread will continue and assert that it is
not blocked, allOf could continue and be executed in a separate thread.allOf
in interface SimpleReactStream<U>
fn
- Function that recieves the results of all currently active
tasks as inputdefault FutureStream<U> peek(java.util.function.Consumer<? super U> consumer)
SimpleReactStream
peek
in interface org.jooq.lambda.Seq<U>
peek
in interface SimpleReactStream<U>
peek
in interface java.util.stream.Stream<U>
consumer
- That will recieve current resultsdefault FutureStream<U> filter(java.util.function.Predicate<? super U> p)
SimpleReactStream
filter
in interface org.jooq.lambda.Seq<U>
filter
in interface SimpleReactStream<U>
filter
in interface java.util.stream.Stream<U>
p
- Predicate that will be used to filter elements from the
dataflowdefault void forEach(java.util.function.Consumer<? super U> action)
default void forEachOrdered(java.util.function.Consumer<? super U> action)
forEachOrdered
in interface java.util.stream.Stream<U>
default java.lang.Object[] toArray()
toArray
in interface java.util.stream.Stream<U>
default <A> A[] toArray(java.util.function.IntFunction<A[]> generator)
toArray
in interface java.util.stream.Stream<U>
default U reduce(U identity, java.util.function.BinaryOperator<U> accumulator)
reduce
in interface java.util.stream.Stream<U>
default java.util.Optional<U> reduce(java.util.function.BinaryOperator<U> accumulator)
reduce
in interface java.util.stream.Stream<U>
default <R> R collect(java.util.function.Supplier<R> supplier, java.util.function.BiConsumer<R,? super U> accumulator, java.util.function.BiConsumer<R,R> combiner)
collect
in interface java.util.stream.Stream<U>
default java.util.Optional<U> min(java.util.Comparator<? super U> comparator)
min
in interface java.util.stream.Stream<U>
default java.util.Optional<U> max(java.util.Comparator<? super U> comparator)
max
in interface java.util.stream.Stream<U>
default long count()
count
in interface java.util.stream.Stream<U>
default boolean anyMatch(java.util.function.Predicate<? super U> predicate)
anyMatch
in interface java.util.stream.Stream<U>
default boolean allMatch(java.util.function.Predicate<? super U> predicate)
allMatch
in interface java.util.stream.Stream<U>
default boolean noneMatch(java.util.function.Predicate<? super U> predicate)
noneMatch
in interface java.util.stream.Stream<U>
default java.util.Optional<U> findFirst()
findFirst
in interface java.util.stream.Stream<U>
default java.util.Optional<U> findAny()
findAny
in interface java.util.stream.Stream<U>
default <R> R reduce(R identity, java.util.function.BiFunction<R,? super U,R> accumulator, java.util.function.BinaryOperator<R> combiner)
reduce
in interface java.util.stream.Stream<U>
default CloseableIterator<U> iterator()
default FutureStream<U> reverse()
reverse
in interface org.jooq.lambda.Seq<U>
default java.util.Iterator<U> reversedIterator()
default java.util.Spliterator<U> spliterator()
default boolean isParallel()
default org.jooq.lambda.Seq<U> sequential()
default java.util.stream.Stream<U> stream()
stream
in interface org.jooq.lambda.Seq<U>
default FutureStream<U> intersperse(U value)
intersperse
in interface org.jooq.lambda.Seq<U>
Seq.intersperse(Stream, Object)
default <U> FutureStream<U> cast(java.lang.Class<U> type)
cast
in interface org.jooq.lambda.Seq<U>
default <U> FutureStream<U> ofType(java.lang.Class<U> type)
ofType
in interface org.jooq.lambda.Seq<U>
static <T,U> FutureStream<U> ofType(FutureStream<T> stream, java.lang.Class<U> type)
static <T,U> FutureStream<U> cast(FutureStream<T> stream, java.lang.Class<U> type)
ClassCastException
.
// ClassCastException LazyFutureStream.of(1, "a", 2, "b",
3).cast(Integer.class)static <T> FutureStream<T> intersperse(FutureStream<T> stream, T value)
default FutureStream<U> unordered()
default org.jooq.lambda.Seq<U> onClose(java.lang.Runnable closeHandler)
default void close()
default <R> FutureStream<R> map(java.util.function.Function<? super U,? extends R> mapper)
default java.util.stream.IntStream mapToInt(java.util.function.ToIntFunction<? super U> mapper)
default java.util.stream.LongStream mapToLong(java.util.function.ToLongFunction<? super U> mapper)
default java.util.stream.DoubleStream mapToDouble(java.util.function.ToDoubleFunction<? super U> mapper)
default java.util.stream.IntStream flatMapToInt(java.util.function.Function<? super U,? extends java.util.stream.IntStream> mapper)
default java.util.stream.LongStream flatMapToLong(java.util.function.Function<? super U,? extends java.util.stream.LongStream> mapper)
default java.util.stream.DoubleStream flatMapToDouble(java.util.function.Function<? super U,? extends java.util.stream.DoubleStream> mapper)
default org.jooq.lambda.Seq<U> sorted()
default FutureStream<U> self(java.util.function.Consumer<FutureStream<U>> consumer)
consumer
- Consumer that will recieve current stagedefault org.jooq.lambda.Seq<U> slice(long from, long to)
slice
in interface org.jooq.lambda.Seq<U>
Seq.slice(Stream, long, long)
static <T> org.jooq.lambda.Seq<T> slice(FutureStream<T> stream, long from, long to)
static <R> FutureStream<R> merge(FutureStream s1, FutureStream s2)
s1
- Reactive stage builder to merges2
- Reactive stage builder to mergedefault FutureStream<U> sync()
sync
in interface SimpleReactStream<U>
default FutureStream<U> async()
async
in interface SimpleReactStream<U>