Package dev.demeng.pluginbase.promise
Interface Promise<V>
- Type Parameters:
V- the result type
- All Superinterfaces:
AutoCloseable,Future<V>,Terminable
An object that acts as a proxy for a result that is initially unknown, usually because the
computation of its value is yet incomplete.
This interface carries similar method signatures to those of CompletionStage and CompletableFuture.
However, a distinction is made between actions which are executed on the main server thread vs asynchronously.
-
Field Summary
Fields inherited from interface dev.demeng.pluginbase.terminable.Terminable
EMPTY -
Method Summary
Modifier and TypeMethodDescriptiondefault booleancancel()Attempts to cancel execution of this task.static <U> @NotNull Promise<U>completed(U value) Returns a Promise which is already completed with the given value.static <U> @NotNull Promise<U>empty()Returns a new empty Promiseexceptionally(@NotNull ThreadContext context, @NotNull Function<Throwable, ? extends V> fn) Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function.static <U> @NotNull Promise<U>exceptionally(@NotNull Throwable exception) Returns a Promise which is already completed with the given exception.exceptionallyAsync(@NotNull Function<Throwable, ? extends V> fn) Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function.exceptionallyDelayed(@NotNull ThreadContext context, @NotNull Function<Throwable, ? extends V> fn, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed.exceptionallyDelayed(@NotNull ThreadContext context, @NotNull Function<Throwable, ? extends V> fn, long delay, @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed.exceptionallyDelayedAsync(@NotNull Function<Throwable, ? extends V> fn, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed.exceptionallyDelayedAsync(@NotNull Function<Throwable, ? extends V> fn, long delay, @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed.exceptionallyDelayedSync(@NotNull Function<Throwable, ? extends V> fn, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed.exceptionallyDelayedSync(@NotNull Function<Throwable, ? extends V> fn, long delay, @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed.exceptionallySync(@NotNull Function<Throwable, ? extends V> fn) Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function.Returns the result value (or throws any encountered exception) if completed, else returns the given valueIfAbsent.join()Returns the result value when complete, or throws an (unchecked) exception if completed exceptionally.start()Returns a new base promise to be built on top of.supply(@NotNull ThreadContext context, @NotNull Supplier<V> supplier) Schedules the supply of the Promise's result, via the given supplier.Supplies the Promise's result.supplyAsync(@NotNull Supplier<V> supplier) Schedules the supply of the Promise's result, via the given supplier.supplyDelayed(@NotNull ThreadContext context, @NotNull Supplier<V> supplier, long delayTicks) Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.supplyDelayed(@NotNull ThreadContext context, @NotNull Supplier<V> supplier, long delay, @NotNull TimeUnit unit) Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.supplyDelayedAsync(@NotNull Supplier<V> supplier, long delayTicks) Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.supplyDelayedAsync(@NotNull Supplier<V> supplier, long delay, @NotNull TimeUnit unit) Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.supplyDelayedSync(@NotNull Supplier<V> supplier, long delayTicks) Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.supplyDelayedSync(@NotNull Supplier<V> supplier, long delay, @NotNull TimeUnit unit) Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.supplyException(@NotNull Throwable exception) Supplies an exceptional result to the Promise.supplyExceptionally(@NotNull ThreadContext context, @NotNull Callable<V> callable) Schedules the supply of the Promise's result, via the given callable.supplyExceptionallyAsync(@NotNull Callable<V> callable) Schedules the supply of the Promise's result, via the given callable.supplyExceptionallyDelayed(@NotNull ThreadContext context, @NotNull Callable<V> callable, long delayTicks) Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.supplyExceptionallyDelayed(@NotNull ThreadContext context, @NotNull Callable<V> callable, long delay, @NotNull TimeUnit unit) Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.supplyExceptionallyDelayedAsync(@NotNull Callable<V> callable, long delayTicks) Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.supplyExceptionallyDelayedAsync(@NotNull Callable<V> callable, long delay, @NotNull TimeUnit unit) Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.supplyExceptionallyDelayedSync(@NotNull Callable<V> callable, long delayTicks) Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.supplyExceptionallyDelayedSync(@NotNull Callable<V> callable, long delay, @NotNull TimeUnit unit) Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.supplyExceptionallySync(@NotNull Callable<V> callable) Schedules the supply of the Promise's result, via the given callable.static <U> @NotNull Promise<U>supplying(@NotNull ThreadContext context, @NotNull Supplier<U> supplier) Returns a new Promise, and schedules it's population via the given supplier.static <U> @NotNull Promise<U>supplyingAsync(@NotNull Supplier<U> supplier) Returns a new Promise, and schedules it's population via the given supplier.static <U> @NotNull Promise<U>supplyingDelayed(@NotNull ThreadContext context, @NotNull Supplier<U> supplier, long delayTicks) Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.static <U> @NotNull Promise<U>supplyingDelayed(@NotNull ThreadContext context, @NotNull Supplier<U> supplier, long delay, @NotNull TimeUnit unit) Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.static <U> @NotNull Promise<U>supplyingDelayedAsync(@NotNull Supplier<U> supplier, long delayTicks) Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.static <U> @NotNull Promise<U>supplyingDelayedAsync(@NotNull Supplier<U> supplier, long delay, @NotNull TimeUnit unit) Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.static <U> @NotNull Promise<U>supplyingDelayedSync(@NotNull Supplier<U> supplier, long delayTicks) Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.static <U> @NotNull Promise<U>supplyingDelayedSync(@NotNull Supplier<U> supplier, long delay, @NotNull TimeUnit unit) Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.static <U> @NotNull Promise<U>supplyingExceptionally(@NotNull ThreadContext context, @NotNull Callable<U> callable) Returns a new Promise, and schedules it's population via the given callable.static <U> @NotNull Promise<U>supplyingExceptionallyAsync(@NotNull Callable<U> callable) Returns a new Promise, and schedules it's population via the given callable.static <U> @NotNull Promise<U>supplyingExceptionallyDelayed(@NotNull ThreadContext context, @NotNull Callable<U> callable, long delayTicks) Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.static <U> @NotNull Promise<U>supplyingExceptionallyDelayed(@NotNull ThreadContext context, @NotNull Callable<U> callable, long delay, @NotNull TimeUnit unit) Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.static <U> @NotNull Promise<U>supplyingExceptionallyDelayedAsync(@NotNull Callable<U> callable, long delayTicks) Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.static <U> @NotNull Promise<U>supplyingExceptionallyDelayedAsync(@NotNull Callable<U> callable, long delay, @NotNull TimeUnit unit) Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.static <U> @NotNull Promise<U>supplyingExceptionallyDelayedSync(@NotNull Callable<U> callable, long delayTicks) Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.static <U> @NotNull Promise<U>supplyingExceptionallyDelayedSync(@NotNull Callable<U> callable, long delay, @NotNull TimeUnit unit) Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.static <U> @NotNull Promise<U>supplyingExceptionallySync(@NotNull Callable<U> callable) Returns a new Promise, and schedules it's population via the given callable.static <U> @NotNull Promise<U>supplyingSync(@NotNull Supplier<U> supplier) Returns a new Promise, and schedules it's population via the given supplier.supplySync(@NotNull Supplier<V> supplier) Schedules the supply of the Promise's result, via the given supplier.thenAccept(@NotNull ThreadContext context, @NotNull Consumer<? super V> action) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action.thenAcceptAsync(@NotNull Consumer<? super V> action) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action.thenAcceptDelayed(@NotNull ThreadContext context, @NotNull Consumer<? super V> action, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.thenAcceptDelayed(@NotNull ThreadContext context, @NotNull Consumer<? super V> action, long delay, @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.thenAcceptDelayedAsync(@NotNull Consumer<? super V> action, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.thenAcceptDelayedAsync(@NotNull Consumer<? super V> action, long delay, @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.thenAcceptDelayedSync(@NotNull Consumer<? super V> action, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.thenAcceptDelayedSync(@NotNull Consumer<? super V> action, long delay, @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.thenAcceptSync(@NotNull Consumer<? super V> action) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action.default <U> @NotNull Promise<U>thenApply(@NotNull ThreadContext context, @NotNull Function<? super V, ? extends U> fn) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.<U> @NotNull Promise<U>thenApplyAsync(@NotNull Function<? super V, ? extends U> fn) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.default <U> @NotNull Promise<U>thenApplyDelayed(@NotNull ThreadContext context, @NotNull Function<? super V, ? extends U> fn, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.default <U> @NotNull Promise<U>thenApplyDelayed(@NotNull ThreadContext context, @NotNull Function<? super V, ? extends U> fn, long delay, @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.<U> @NotNull Promise<U>thenApplyDelayedAsync(@NotNull Function<? super V, ? extends U> fn, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.<U> @NotNull Promise<U>thenApplyDelayedAsync(@NotNull Function<? super V, ? extends U> fn, long delay, @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.<U> @NotNull Promise<U>thenApplyDelayedSync(@NotNull Function<? super V, ? extends U> fn, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.<U> @NotNull Promise<U>thenApplyDelayedSync(@NotNull Function<? super V, ? extends U> fn, long delay, @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.<U> @NotNull Promise<U>thenApplySync(@NotNull Function<? super V, ? extends U> fn) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.default <U> @NotNull Promise<U>thenCompose(@NotNull ThreadContext context, @NotNull Function<? super V, ? extends Promise<U>> fn) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.<U> @NotNull Promise<U>thenComposeAsync(@NotNull Function<? super V, ? extends Promise<U>> fn) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.<U> @NotNull Promise<U>thenComposeDelayedAsync(@NotNull Function<? super V, ? extends Promise<U>> fn, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.<U> @NotNull Promise<U>thenComposeDelayedAsync(@NotNull Function<? super V, ? extends Promise<U>> fn, long delay, @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.default <U> @NotNull Promise<U>thenComposeDelayedSync(@NotNull ThreadContext context, @NotNull Function<? super V, ? extends Promise<U>> fn, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.default <U> @NotNull Promise<U>thenComposeDelayedSync(@NotNull ThreadContext context, @NotNull Function<? super V, ? extends Promise<U>> fn, long delay, @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.<U> @NotNull Promise<U>thenComposeDelayedSync(@NotNull Function<? super V, ? extends Promise<U>> fn, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.<U> @NotNull Promise<U>thenComposeDelayedSync(@NotNull Function<? super V, ? extends Promise<U>> fn, long delay, @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.<U> @NotNull Promise<U>thenComposeSync(@NotNull Function<? super V, ? extends Promise<U>> fn) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.thenRun(@NotNull ThreadContext context, @NotNull Runnable action) Returns a new Promise that, when this promise completes normally, executes the given task.thenRunAsync(@NotNull Runnable action) Returns a new Promise that, when this promise completes normally, executes the given task.thenRunDelayed(@NotNull ThreadContext context, @NotNull Runnable action, long delayTicks) Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.thenRunDelayed(@NotNull ThreadContext context, @NotNull Runnable action, long delay, @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.thenRunDelayedAsync(@NotNull Runnable action, long delayTicks) Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.thenRunDelayedAsync(@NotNull Runnable action, long delay, @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.thenRunDelayedSync(@NotNull Runnable action, long delayTicks) Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.thenRunDelayedSync(@NotNull Runnable action, long delay, @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.thenRunSync(@NotNull Runnable action) Returns a new Promise that, when this promise completes normally, executes the given task.Returns aCompletableFuturemaintaining the same completion properties as this Promise.Methods inherited from interface dev.demeng.pluginbase.terminable.Terminable
bindWith, close, closeAndReportException, closeSilently, isClosed
-
Method Details
-
empty
Returns a new empty PromiseAn empty promise can be 'completed' via the supply methods.
- Type Parameters:
U- the result type- Returns:
- a new empty promise
-
start
Returns a new base promise to be built on top of.- Returns:
- a new promise
-
completed
Returns a Promise which is already completed with the given value.- Type Parameters:
U- the result type- Parameters:
value- the value- Returns:
- a new completed promise
-
exceptionally
Returns a Promise which is already completed with the given exception.- Type Parameters:
U- the result type- Parameters:
exception- the exception- Returns:
- the new completed promise
-
supplying
@NotNull static <U> @NotNull Promise<U> supplying(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Supplier<U> supplier) Returns a new Promise, and schedules it's population via the given supplier.- Type Parameters:
U- the result type- Parameters:
context- the type of executor to use to supply the promisesupplier- the value supplier- Returns:
- the promise
-
supplyingSync
Returns a new Promise, and schedules it's population via the given supplier.- Type Parameters:
U- the result type- Parameters:
supplier- the value supplier- Returns:
- the promise
-
supplyingAsync
Returns a new Promise, and schedules it's population via the given supplier.- Type Parameters:
U- the result type- Parameters:
supplier- the value supplier- Returns:
- the promise
-
supplyingDelayed
@NotNull static <U> @NotNull Promise<U> supplyingDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Supplier<U> supplier, long delayTicks) Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
context- the type of executor to use to supply the promisesupplier- the value supplierdelayTicks- the delay in ticks- Returns:
- the promise
-
supplyingDelayed
@NotNull static <U> @NotNull Promise<U> supplyingDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Supplier<U> supplier, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
context- the type of executor to use to supply the promisesupplier- the value supplierdelay- the delayunit- the unit of delay- Returns:
- the promise
-
supplyingDelayedSync
@NotNull static <U> @NotNull Promise<U> supplyingDelayedSync(@NotNull @NotNull Supplier<U> supplier, long delayTicks) Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
supplier- the value supplierdelayTicks- the delay in ticks- Returns:
- the promise
-
supplyingDelayedSync
@NotNull static <U> @NotNull Promise<U> supplyingDelayedSync(@NotNull @NotNull Supplier<U> supplier, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
supplier- the value supplierdelay- the delayunit- the unit of delay- Returns:
- the promise
-
supplyingDelayedAsync
@NotNull static <U> @NotNull Promise<U> supplyingDelayedAsync(@NotNull @NotNull Supplier<U> supplier, long delayTicks) Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
supplier- the value supplierdelayTicks- the delay in ticks- Returns:
- the promise
-
supplyingDelayedAsync
@NotNull static <U> @NotNull Promise<U> supplyingDelayedAsync(@NotNull @NotNull Supplier<U> supplier, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise, and schedules it's population via the given supplier, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
supplier- the value supplierdelay- the delayunit- the unit of delay- Returns:
- the promise
-
supplyingExceptionally
@NotNull static <U> @NotNull Promise<U> supplyingExceptionally(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Callable<U> callable) Returns a new Promise, and schedules it's population via the given callable.- Type Parameters:
U- the result type- Parameters:
context- the type of executor to use to supply the promisecallable- the value callable- Returns:
- the promise
-
supplyingExceptionallySync
@NotNull static <U> @NotNull Promise<U> supplyingExceptionallySync(@NotNull @NotNull Callable<U> callable) Returns a new Promise, and schedules it's population via the given callable.- Type Parameters:
U- the result type- Parameters:
callable- the value callable- Returns:
- the promise
-
supplyingExceptionallyAsync
@NotNull static <U> @NotNull Promise<U> supplyingExceptionallyAsync(@NotNull @NotNull Callable<U> callable) Returns a new Promise, and schedules it's population via the given callable.- Type Parameters:
U- the result type- Parameters:
callable- the value callable- Returns:
- the promise
-
supplyingExceptionallyDelayed
@NotNull static <U> @NotNull Promise<U> supplyingExceptionallyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Callable<U> callable, long delayTicks) Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
context- the type of executor to use to supply the promisecallable- the value callabledelayTicks- the delay in ticks- Returns:
- the promise
-
supplyingExceptionallyDelayed
@NotNull static <U> @NotNull Promise<U> supplyingExceptionallyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Callable<U> callable, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
context- the type of executor to use to supply the promisecallable- the value callabledelay- the delayunit- the unit of delay- Returns:
- the promise
-
supplyingExceptionallyDelayedSync
@NotNull static <U> @NotNull Promise<U> supplyingExceptionallyDelayedSync(@NotNull @NotNull Callable<U> callable, long delayTicks) Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
callable- the value callabledelayTicks- the delay in ticks- Returns:
- the promise
-
supplyingExceptionallyDelayedSync
@NotNull static <U> @NotNull Promise<U> supplyingExceptionallyDelayedSync(@NotNull @NotNull Callable<U> callable, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
callable- the value callabledelay- the delayunit- the unit of delay- Returns:
- the promise
-
supplyingExceptionallyDelayedAsync
@NotNull static <U> @NotNull Promise<U> supplyingExceptionallyDelayedAsync(@NotNull @NotNull Callable<U> callable, long delayTicks) Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
callable- the value callabledelayTicks- the delay in ticks- Returns:
- the promise
-
supplyingExceptionallyDelayedAsync
@NotNull static <U> @NotNull Promise<U> supplyingExceptionallyDelayedAsync(@NotNull @NotNull Callable<U> callable, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise, and schedules it's population via the given callable, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
callable- the value callabledelay- the delayunit- the unit of delay- Returns:
- the promise
-
cancel
default boolean cancel()Attempts to cancel execution of this task.- Returns:
falseif the task could not be cancelled, typically because it has already completed normally;trueotherwise
-
join
V join()Returns the result value when complete, or throws an (unchecked) exception if completed exceptionally.To better conform with the use of common functional forms, if a computation involved in the completion of this Promise threw an exception, this method throws an (unchecked)
CompletionExceptionwith the underlying exception as its cause.- Returns:
- the result value
- Throws:
CancellationException- if the computation was cancelledCompletionException- if this future completed exceptionally or a completion computation threw an exception
-
getNow
Returns the result value (or throws any encountered exception) if completed, else returns the given valueIfAbsent.- Parameters:
valueIfAbsent- the value to return if not completed- Returns:
- the result value, if completed, else the given valueIfAbsent
- Throws:
CancellationException- if the computation was cancelledCompletionException- if this future completed exceptionally or a completion computation threw an exception
-
supply
Supplies the Promise's result.- Parameters:
value- the object to pass to the promise- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
supplyException
Supplies an exceptional result to the Promise.- Parameters:
exception- the exception to supply- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
supply
@NotNull default @NotNull Promise<V> supply(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Supplier<V> supplier) Schedules the supply of the Promise's result, via the given supplier.- Parameters:
context- the type of executor to use to supply the promisesupplier- the supplier- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
supplySync
Schedules the supply of the Promise's result, via the given supplier.- Parameters:
supplier- the supplier- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
supplyAsync
Schedules the supply of the Promise's result, via the given supplier.- Parameters:
supplier- the supplier- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
supplyDelayed
@NotNull default @NotNull Promise<V> supplyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Supplier<V> supplier, long delayTicks) Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.- Parameters:
context- the type of executor to use to supply the promisesupplier- the supplierdelayTicks- the delay in ticks- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
supplyDelayed
@NotNull default @NotNull Promise<V> supplyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Supplier<V> supplier, long delay, @NotNull @NotNull TimeUnit unit) Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.- Parameters:
context- the type of executor to use to supply the promisesupplier- the supplierdelay- the delayunit- the unit of delay- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
supplyDelayedSync
@NotNull @NotNull Promise<V> supplyDelayedSync(@NotNull @NotNull Supplier<V> supplier, long delayTicks) Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.- Parameters:
supplier- the supplierdelayTicks- the delay in ticks- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
supplyDelayedSync
@NotNull @NotNull Promise<V> supplyDelayedSync(@NotNull @NotNull Supplier<V> supplier, long delay, @NotNull @NotNull TimeUnit unit) Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.- Parameters:
supplier- the supplierdelay- the delayunit- the unit of delay- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
supplyDelayedAsync
@NotNull @NotNull Promise<V> supplyDelayedAsync(@NotNull @NotNull Supplier<V> supplier, long delayTicks) Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.- Parameters:
supplier- the supplierdelayTicks- the delay in ticks- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
supplyDelayedAsync
@NotNull @NotNull Promise<V> supplyDelayedAsync(@NotNull @NotNull Supplier<V> supplier, long delay, @NotNull @NotNull TimeUnit unit) Schedules the supply of the Promise's result, via the given supplier, after the delay has elapsed.- Parameters:
supplier- the supplierdelay- the delayunit- the unit of delay- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
supplyExceptionally
@NotNull default @NotNull Promise<V> supplyExceptionally(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Callable<V> callable) Schedules the supply of the Promise's result, via the given callable.- Parameters:
context- the type of executor to use to supply the promisecallable- the callable- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
supplyExceptionallySync
Schedules the supply of the Promise's result, via the given callable.- Parameters:
callable- the callable- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
supplyExceptionallyAsync
Schedules the supply of the Promise's result, via the given callable.- Parameters:
callable- the callable- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
supplyExceptionallyDelayed
@NotNull default @NotNull Promise<V> supplyExceptionallyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Callable<V> callable, long delayTicks) Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.- Parameters:
context- the type of executor to use to supply the promisecallable- the callabledelayTicks- the delay in ticks- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
supplyExceptionallyDelayed
@NotNull default @NotNull Promise<V> supplyExceptionallyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Callable<V> callable, long delay, @NotNull @NotNull TimeUnit unit) Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.- Parameters:
context- the type of executor to use to supply the promisecallable- the callabledelay- the delayunit- the unit of delay- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
supplyExceptionallyDelayedSync
@NotNull @NotNull Promise<V> supplyExceptionallyDelayedSync(@NotNull @NotNull Callable<V> callable, long delayTicks) Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.- Parameters:
callable- the callabledelayTicks- the delay in ticks- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
supplyExceptionallyDelayedSync
@NotNull @NotNull Promise<V> supplyExceptionallyDelayedSync(@NotNull @NotNull Callable<V> callable, long delay, @NotNull @NotNull TimeUnit unit) Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.- Parameters:
callable- the callabledelay- the delayunit- the unit of delay- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
supplyExceptionallyDelayedAsync
@NotNull @NotNull Promise<V> supplyExceptionallyDelayedAsync(@NotNull @NotNull Callable<V> callable, long delayTicks) Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.- Parameters:
callable- the callabledelayTicks- the delay in ticks- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
supplyExceptionallyDelayedAsync
@NotNull @NotNull Promise<V> supplyExceptionallyDelayedAsync(@NotNull @NotNull Callable<V> callable, long delay, @NotNull @NotNull TimeUnit unit) Schedules the supply of the Promise's result, via the given callable, after the delay has elapsed.- Parameters:
callable- the callabledelay- the delayunit- the unit of delay- Returns:
- the same promise
- Throws:
IllegalStateException- if the promise is already being supplied, or has already been completed.
-
thenApply
@NotNull default <U> @NotNull Promise<U> thenApply(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Function<? super V, ? extends U> fn) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.- Type Parameters:
U- the result type- Parameters:
context- the type of executor to use to supply the promisefn- the function to use to compute the value- Returns:
- the new promise
-
thenApplySync
@NotNull <U> @NotNull Promise<U> thenApplySync(@NotNull @NotNull Function<? super V, ? extends U> fn) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.- Type Parameters:
U- the result type- Parameters:
fn- the function to use to compute the value- Returns:
- the new promise
-
thenApplyAsync
@NotNull <U> @NotNull Promise<U> thenApplyAsync(@NotNull @NotNull Function<? super V, ? extends U> fn) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.- Type Parameters:
U- the result type- Parameters:
fn- the function to use to compute the value- Returns:
- the new promise
-
thenApplyDelayed
@NotNull default <U> @NotNull Promise<U> thenApplyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Function<? super V, ? extends U> fn, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
context- the type of executor to use to supply the promisefn- the function to use to compute the valuedelayTicks- the delay in ticks- Returns:
- the new promise
-
thenApplyDelayed
@NotNull default <U> @NotNull Promise<U> thenApplyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Function<? super V, ? extends U> fn, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
context- the type of executor to use to supply the promisefn- the function to use to compute the valuedelay- the delayunit- the unit of delay- Returns:
- the new promise
-
thenApplyDelayedSync
@NotNull <U> @NotNull Promise<U> thenApplyDelayedSync(@NotNull @NotNull Function<? super V, ? extends U> fn, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
fn- the function to use to compute the valuedelayTicks- the delay in ticks- Returns:
- the new promise
-
thenApplyDelayedSync
@NotNull <U> @NotNull Promise<U> thenApplyDelayedSync(@NotNull @NotNull Function<? super V, ? extends U> fn, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
fn- the function to use to compute the valuedelay- the delayunit- the unit of delay- Returns:
- the new promise
-
thenApplyDelayedAsync
@NotNull <U> @NotNull Promise<U> thenApplyDelayedAsync(@NotNull @NotNull Function<? super V, ? extends U> fn, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
fn- the function to use to compute the valuedelayTicks- the delay in ticks- Returns:
- the new promise
-
thenApplyDelayedAsync
@NotNull <U> @NotNull Promise<U> thenApplyDelayedAsync(@NotNull @NotNull Function<? super V, ? extends U> fn, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
fn- the function to use to compute the valuedelay- the delayunit- the unit of delay- Returns:
- the new promise
-
thenAccept
@NotNull default @NotNull Promise<Void> thenAccept(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Consumer<? super V> action) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action.- Parameters:
context- the type of executor to use to supply the promiseaction- the action to perform before completing the returned future- Returns:
- the new promise
-
thenAcceptSync
@NotNull default @NotNull Promise<Void> thenAcceptSync(@NotNull @NotNull Consumer<? super V> action) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action.- Parameters:
action- the action to perform before completing the returned future- Returns:
- the new promise
-
thenAcceptAsync
@NotNull default @NotNull Promise<Void> thenAcceptAsync(@NotNull @NotNull Consumer<? super V> action) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action.- Parameters:
action- the action to perform before completing the returned future- Returns:
- the new promise
-
thenAcceptDelayed
@NotNull default @NotNull Promise<Void> thenAcceptDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Consumer<? super V> action, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.- Parameters:
context- the type of executor to use to supply the promiseaction- the action to perform before completing the returned futuredelayTicks- the delay in ticks- Returns:
- the new promise
-
thenAcceptDelayed
@NotNull default @NotNull Promise<Void> thenAcceptDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Consumer<? super V> action, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.- Parameters:
context- the type of executor to use to supply the promiseaction- the action to perform before completing the returned futuredelay- the delayunit- the unit of delay- Returns:
- the new promise
-
thenAcceptDelayedSync
@NotNull default @NotNull Promise<Void> thenAcceptDelayedSync(@NotNull @NotNull Consumer<? super V> action, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.- Parameters:
action- the action to perform before completing the returned futuredelayTicks- the delay in ticks- Returns:
- the new promise
-
thenAcceptDelayedSync
@NotNull default @NotNull Promise<Void> thenAcceptDelayedSync(@NotNull @NotNull Consumer<? super V> action, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.- Parameters:
action- the action to perform before completing the returned futuredelay- the delayunit- the unit of delay- Returns:
- the new promise
-
thenAcceptDelayedAsync
@NotNull default @NotNull Promise<Void> thenAcceptDelayedAsync(@NotNull @NotNull Consumer<? super V> action, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.- Parameters:
action- the action to perform before completing the returned futuredelayTicks- the delay in ticks- Returns:
- the new promise
-
thenAcceptDelayedAsync
@NotNull default @NotNull Promise<Void> thenAcceptDelayedAsync(@NotNull @NotNull Consumer<? super V> action, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given action, after the delay has elapsed.- Parameters:
action- the action to perform before completing the returned futuredelay- the delayunit- the unit of delay- Returns:
- the new promise
-
thenRun
@NotNull default @NotNull Promise<Void> thenRun(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Runnable action) Returns a new Promise that, when this promise completes normally, executes the given task.- Parameters:
context- the type of executor to use to supply the promiseaction- the action to run before completing the returned future- Returns:
- the new promise
-
thenRunSync
Returns a new Promise that, when this promise completes normally, executes the given task.- Parameters:
action- the action to run before completing the returned future- Returns:
- the new promise
-
thenRunAsync
Returns a new Promise that, when this promise completes normally, executes the given task.- Parameters:
action- the action to run before completing the returned future- Returns:
- the new promise
-
thenRunDelayed
@NotNull default @NotNull Promise<Void> thenRunDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Runnable action, long delayTicks) Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.- Parameters:
context- the type of executor to use to supply the promiseaction- the action to run before completing the returned futuredelayTicks- the delay in ticks- Returns:
- the new promise
-
thenRunDelayed
@NotNull default @NotNull Promise<Void> thenRunDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Runnable action, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.- Parameters:
context- the type of executor to use to supply the promiseaction- the action to run before completing the returned futuredelay- the delayunit- the unit of delay- Returns:
- the new promise
-
thenRunDelayedSync
@NotNull default @NotNull Promise<Void> thenRunDelayedSync(@NotNull @NotNull Runnable action, long delayTicks) Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.- Parameters:
action- the action to run before completing the returned futuredelayTicks- the delay in ticks- Returns:
- the new promise
-
thenRunDelayedSync
@NotNull default @NotNull Promise<Void> thenRunDelayedSync(@NotNull @NotNull Runnable action, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.- Parameters:
action- the action to run before completing the returned futuredelay- the delayunit- the unit of delay- Returns:
- the new promise
-
thenRunDelayedAsync
@NotNull default @NotNull Promise<Void> thenRunDelayedAsync(@NotNull @NotNull Runnable action, long delayTicks) Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.- Parameters:
action- the action to run before completing the returned futuredelayTicks- the delay in ticks- Returns:
- the new promise
-
thenRunDelayedAsync
@NotNull default @NotNull Promise<Void> thenRunDelayedAsync(@NotNull @NotNull Runnable action, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, executes the given task, after the delay has elapsed.- Parameters:
action- the action to run before completing the returned futuredelay- the delayunit- the unit of delay- Returns:
- the new promise
-
thenCompose
@NotNull default <U> @NotNull Promise<U> thenCompose(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Function<? super V, ? extends Promise<U>> fn) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.- Type Parameters:
U- the result type- Parameters:
context- the type of executor to use to supply the promisefn- the function to use to compute the value- Returns:
- the new promise
-
thenComposeSync
@NotNull <U> @NotNull Promise<U> thenComposeSync(@NotNull @NotNull Function<? super V, ? extends Promise<U>> fn) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.- Type Parameters:
U- the result type- Parameters:
fn- the function to use to compute the value- Returns:
- the new promise
-
thenComposeAsync
@NotNull <U> @NotNull Promise<U> thenComposeAsync(@NotNull @NotNull Function<? super V, ? extends Promise<U>> fn) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function.- Type Parameters:
U- the result type- Parameters:
fn- the function to use to compute the value- Returns:
- the new promise
-
thenComposeDelayedSync
@NotNull default <U> @NotNull Promise<U> thenComposeDelayedSync(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Function<? super V, ? extends Promise<U>> fn, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
context- the type of executor to use to supply the promisefn- the function to use to compute the valuedelayTicks- the delay in ticks- Returns:
- the new promise
-
thenComposeDelayedSync
@NotNull default <U> @NotNull Promise<U> thenComposeDelayedSync(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Function<? super V, ? extends Promise<U>> fn, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
context- the type of executor to use to supply the promisefn- the function to use to compute the valuedelay- the delayunit- the unit of delay- Returns:
- the new promise
-
thenComposeDelayedSync
@NotNull <U> @NotNull Promise<U> thenComposeDelayedSync(@NotNull @NotNull Function<? super V, ? extends Promise<U>> fn, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
fn- the function to use to compute the valuedelayTicks- the delay in ticks- Returns:
- the new promise
-
thenComposeDelayedSync
@NotNull <U> @NotNull Promise<U> thenComposeDelayedSync(@NotNull @NotNull Function<? super V, ? extends Promise<U>> fn, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
fn- the function to use to compute the valuedelay- the delayunit- the unit of delay- Returns:
- the new promise
-
thenComposeDelayedAsync
@NotNull <U> @NotNull Promise<U> thenComposeDelayedAsync(@NotNull @NotNull Function<? super V, ? extends Promise<U>> fn, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
fn- the function to use to compute the valuedelayTicks- the delay in ticks- Returns:
- the new promise
-
thenComposeDelayedAsync
@NotNull <U> @NotNull Promise<U> thenComposeDelayedAsync(@NotNull @NotNull Function<? super V, ? extends Promise<U>> fn, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's result as the argument to the given function, after the delay has elapsed.- Type Parameters:
U- the result type- Parameters:
fn- the function to use to compute the valuedelay- the delayunit- the unit of delay- Returns:
- the new promise
-
exceptionally
@NotNull default @NotNull Promise<V> exceptionally(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Function<Throwable, ? extends V> fn) Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function. Otherwise, if this promise completes normally, then the returned promise also completes normally with the same value.- Parameters:
context- the type of executor to use to supply the promisefn- the function to use to compute the value of the returned Promise, if this promise completed exceptionally- Returns:
- the new promise
-
exceptionallySync
@NotNull @NotNull Promise<V> exceptionallySync(@NotNull @NotNull Function<Throwable, ? extends V> fn) Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function. Otherwise, if this promise completes normally, then the returned promise also completes normally with the same value.- Parameters:
fn- the function to use to compute the value of the returned Promise, if this promise completed exceptionally- Returns:
- the new promise
-
exceptionallyAsync
@NotNull @NotNull Promise<V> exceptionallyAsync(@NotNull @NotNull Function<Throwable, ? extends V> fn) Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function. Otherwise, if this promise completes normally, then the returned promise also completes normally with the same value.- Parameters:
fn- the function to use to compute the value of the returned Promise, if this promise completed exceptionally- Returns:
- the new promise
-
exceptionallyDelayed
@NotNull default @NotNull Promise<V> exceptionallyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Function<Throwable, ? extends V> fn, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed. Otherwise, if this promise completes normally, then the returned promise also completes normally with the same value.- Parameters:
context- the type of executor to use to supply the promisefn- the function to use to compute the value of the returned Promise, if this promise completed exceptionallydelayTicks- the delay in ticks- Returns:
- the new promise
-
exceptionallyDelayed
@NotNull default @NotNull Promise<V> exceptionallyDelayed(@NotNull @NotNull ThreadContext context, @NotNull @NotNull Function<Throwable, ? extends V> fn, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed. Otherwise, if this promise completes normally, then the returned promise also completes normally with the same value.- Parameters:
context- the type of executor to use to supply the promisefn- the function to use to compute the value of the returned Promise, if this promise completed exceptionallydelay- the delayunit- the unit of delay- Returns:
- the new promise
-
exceptionallyDelayedSync
@NotNull @NotNull Promise<V> exceptionallyDelayedSync(@NotNull @NotNull Function<Throwable, ? extends V> fn, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed. Otherwise, if this promise completes normally, then the returned promise also completes normally with the same value.- Parameters:
fn- the function to use to compute the value of the returned Promise, if this promise completed exceptionallydelayTicks- the delay in ticks- Returns:
- the new promise
-
exceptionallyDelayedSync
@NotNull @NotNull Promise<V> exceptionallyDelayedSync(@NotNull @NotNull Function<Throwable, ? extends V> fn, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed. Otherwise, if this promise completes normally, then the returned promise also completes normally with the same value.- Parameters:
fn- the function to use to compute the value of the returned Promise, if this promise completed exceptionallydelay- the delayunit- the unit of delay- Returns:
- the new promise
-
exceptionallyDelayedAsync
@NotNull @NotNull Promise<V> exceptionallyDelayedAsync(@NotNull @NotNull Function<Throwable, ? extends V> fn, long delayTicks) Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed. Otherwise, if this promise completes normally, then the returned promise also completes normally with the same value.- Parameters:
fn- the function to use to compute the value of the returned Promise, if this promise completed exceptionallydelayTicks- the delay in ticks- Returns:
- the new promise
-
exceptionallyDelayedAsync
@NotNull @NotNull Promise<V> exceptionallyDelayedAsync(@NotNull @NotNull Function<Throwable, ? extends V> fn, long delay, @NotNull @NotNull TimeUnit unit) Returns a new Promise that, when this promise completes normally, is executed with this promise's exception as the argument to the given function, after the delay has elapsed. Otherwise, if this promise completes normally, then the returned promise also completes normally with the same value.- Parameters:
fn- the function to use to compute the value of the returned Promise, if this promise completed exceptionallydelay- the delayunit- the unit of delay- Returns:
- the new promise
-
toCompletableFuture
CompletableFuture<V> toCompletableFuture()Returns aCompletableFuturemaintaining the same completion properties as this Promise.A Promise implementation that does not choose to interoperate with CompletableFutures may throw
UnsupportedOperationException.- Returns:
- the CompletableFuture
- Throws:
UnsupportedOperationException- if this implementation does not interoperate with CompletableFuture
-