Stage.ThrowingFunction<T,R>| Modifier and Type | Field and Description |
|---|---|
protected Throwable |
exception |
protected BiConsumer<? super T,Throwable> |
next |
protected T |
result |
IGNORE_CALLBACKTIMEOUT_EXCEPTION| Modifier | Constructor and Description |
|---|---|
protected |
SettableStage() |
| Modifier and Type | Method and Description |
|---|---|
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) |
static <T> SettableStage<T> |
create() |
Stage<T> |
either(Stage<? extends T> other)
Combines two
Stage in one. |
boolean |
isComplete() |
boolean |
isSet() |
Stage<T> |
post()
When this stage is completed it's completion will be postponed to the next eventloop tick.
|
Stage<T> |
postTo(Eventloop eventloop) |
void |
set(T result)
Sets the result of this
SettableStage and completes it. |
void |
setException(Throwable t)
Sets exception and completes this
SettableStage exceptionally. |
protected void |
subscribe(BiConsumer<? super T,Throwable> next) |
<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 |
String |
toString() |
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) |
boolean |
trySet(T result)
The same as
trySet(Object, Throwable) )} but for result only. |
boolean |
trySet(T result,
Throwable throwable)
Tries to set result or exception for this
SettableStage if it not yet set. |
boolean |
trySetException(Throwable t)
The same as
trySet(Object, Throwable) )} but for exception only. |
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, wait, wait, waitassertNoCalls, assertNoExceptions, forBiConsumer, forFuture, ignore, set, stageToCallbackof, of, ofCallable, ofCallback, ofCompletionStage, ofException, ofFuture, ofFuture, ofRunnable, ofThrowingRunnable, thenCallbackprotected BiConsumer<? super T,Throwable> next
public static <T> SettableStage<T> create()
public void set(@Nullable T result)
SettableStage and completes it.
AssertionError is thrown when you try to set result for already completed stage.
public void setException(Throwable t)
SettableStage exceptionally.
AssertionError is thrown when you try to set exception for already completed stage.
setException in interface Callback<T>t - exceptionpublic boolean trySet(@Nullable T result)
trySet(Object, Throwable) )} but for result only.public boolean trySetException(Throwable t)
trySet(Object, Throwable) )} but for exception only.public boolean trySet(@Nullable T result, @Nullable Throwable throwable)
SettableStage if it not yet set.
Otherwise do nothing
true if result or exception was set, false otherwiseprotected void subscribe(BiConsumer<? super T,Throwable> next)
public boolean isSet()
true if this SettableStage result is not set, false otherwise.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)
Stagepublic <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.