public abstract class NextStage<T,R> extends Object implements BiConsumer<T,Throwable>
Stage.ThrowingFunction<T,R>| Modifier and Type | Field and Description |
|---|---|
protected BiConsumer<? super T,Throwable> |
next |
TIMEOUT_EXCEPTION| Constructor and Description |
|---|
NextStage() |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(T t,
Throwable throwable) |
Stage<Void> |
both(Stage<?> other)
Combines two
Stage in one and completes when both have been completed. |
<U,V> Stage<V> |
combine(Stage<? extends U> other,
BiFunction<? super T,? super U,? extends V> fn)
Combines two
Stage in one using fn. |
protected void |
complete(T value) |
protected void |
complete(T value,
Throwable error) |
protected void |
completeExceptionally(Throwable error) |
Stage<T> |
either(Stage<? extends T> other)
Combines two
Stage in one. |
boolean |
isComplete() |
protected abstract void |
onComplete(T result) |
protected void |
onCompleteExceptionally(Throwable throwable) |
Stage<T> |
post()
When this stage is completed it's completion will be postponed to the next eventloop tick.
|
Stage<T> |
postTo(Eventloop eventloop) |
protected void |
subscribe(BiConsumer<? super T,Throwable> consumer) |
<U,S extends BiConsumer<? super T,Throwable> & Stage<U>> |
then(S stage)
Executes given stage after execution of this stage completes
|
<U> Stage<U> |
thenApply(Function<? super T,? extends U> fn)
Applies fn to the result of this
Stage |
<U> Stage<U> |
thenApplyEx(BiFunction<? super T,Throwable,? extends U> fn)
Applies fn to the result or exception of this
Stage |
<U> Stage<U> |
thenCompose(Function<? super T,? extends Stage<U>> fn)
Applies function to the result of this stage if it completes successfully.
|
<U> Stage<U> |
thenComposeEx(BiFunction<? super T,Throwable,? extends Stage<U>> fn)
Applies function to the result of this stage.
|
Stage<T> |
thenException(Function<? super T,Throwable> fn) |
Stage<T> |
thenRun(Runnable action)
Runs action after successful completion of this stage
|
Stage<T> |
thenRunEx(Runnable action)
Runs action after completion of this stage
|
<U> Stage<U> |
thenTry(Stage.ThrowingFunction<? super T,? extends U> fn) |
Stage<T> |
timeout(Duration timeout)
Returns stage that completes successfully if this stage completes before timeout.
|
CompletableFuture<T> |
toCompletableFuture()
Wraps
Stage into CompletableFuture |
Stage<Try<T>> |
toTry()
Returns stage that always completes successfully with result or exception wrapped in Try
|
Stage<Void> |
toVoid()
Waits for result and discard it.
|
protected void |
tryComplete(T value) |
protected void |
tryComplete(T value,
Throwable error) |
protected void |
tryCompleteExceptionally(Throwable error) |
Stage<T> |
whenComplete(BiConsumer<? super T,Throwable> action)
Subscribes given action to be executed after this stage completes
|
Stage<T> |
whenException(Consumer<Throwable> action)
Subscribes given action to be executed after this stage completes exceptionally
|
Stage<T> |
whenResult(Consumer<? super T> action)
Subscribes given action to be executed after this stage completes successfully
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitandThenof, of, ofCallable, ofCallback, ofCompletionStage, ofException, ofFuture, ofFuture, ofRunnable, ofThrowingRunnable, thenCallbackprotected BiConsumer<? super T,Throwable> next
protected abstract void onComplete(T result)
protected void onCompleteExceptionally(Throwable throwable)
public final void accept(T t, Throwable throwable)
accept in interface BiConsumer<T,Throwable>public boolean isComplete()
protected void complete(@Nullable T value)
protected void tryComplete(@Nullable T value)
protected void tryCompleteExceptionally(Throwable error)
public <U,S extends BiConsumer<? super T,Throwable> & Stage<U>> Stage<U> then(S stage)
Stageprotected void subscribe(BiConsumer<? super T,Throwable> consumer)
public <U> Stage<U> thenApply(Function<? super T,? extends U> fn)
StageStagepublic <U> Stage<U> thenApplyEx(BiFunction<? super T,Throwable,? extends U> fn)
StageStagethenApplyEx in interface Stage<T>fn - function to applyStage that will apply given functionpublic Stage<T> whenResult(Consumer<? super T> action)
StagewhenResult in interface Stage<T>action - to be executedStagepublic Stage<T> thenRun(Runnable action)
Stagepublic Stage<T> thenRunEx(Runnable action)
Stagepublic <U> Stage<U> thenCompose(Function<? super T,? extends Stage<U>> fn)
StagethenCompose in interface Stage<T>fn - to be appliedpublic <U> Stage<U> thenComposeEx(BiFunction<? super T,Throwable,? extends Stage<U>> fn)
StagethenComposeEx in interface Stage<T>fn - to be appliedpublic Stage<T> whenComplete(BiConsumer<? super T,Throwable> action)
StagewhenComplete in interface Stage<T>action - to be executedStagepublic Stage<T> whenException(Consumer<Throwable> action)
StagewhenException in interface Stage<T>action - to be executedStagepublic Stage<T> thenException(Function<? super T,Throwable> fn)
thenException in interface Stage<T>public <U> Stage<U> thenTry(Stage.ThrowingFunction<? super T,? extends U> fn)
public <U,V> Stage<V> combine(Stage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)
StageStage in one using fn.public Stage<Void> both(Stage<?> other)
StageStage in one and completes when both have been completed.public Stage<T> either(Stage<? extends T> other)
StageStage in one.public Stage<T> post()
Stagepublic Stage<Try<T>> toTry()
Stagepublic Stage<Void> toVoid()
Stagepublic Stage<T> timeout(@Nullable Duration timeout)
Stagenull is given, no timeout is applied.public CompletableFuture<T> toCompletableFuture()
StageStage into CompletableFuturetoCompletableFuture in interface Stage<T>Copyright © 2019. All rights reserved.