Interface Promise.Invocable<R>
- Type Parameters:
R- The result type
- All Known Subinterfaces:
Blocker.Promise<C>
- All Known Implementing Classes:
Promise.Invocable.Abstract, Promise.Invocable.NonBlocking
An
Invocable Promise that provides
the Invocable.InvocationType of calls to Promise.succeeded(Object).-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classAbstract implementation ofPromise.Invocablewith the specifiedInvocable.InvocationType.static classAbstract implementation ofPromise.InvocablewithInvocable.InvocationTypeset toInvocable.InvocationType.NON_BLOCKING.Nested classes/interfaces inherited from interface Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.TaskNested classes/interfaces inherited from interface Promise
Promise.Completable<S>, Promise.Invocable<R>, Promise.Task<T>, Promise.Wrapper<W> -
Field Summary
Fields inherited from interface Invocable
__nonBlocking, NOOP -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic <T> Promise.Invocable<T> from(Runnable beforeComplete, Promise.Invocable<T> promise) Returns a promise that, when it is completed, runs the givenRunnableand then completes the given promise.static <T> Promise.Invocable<T> from(Promise.Invocable<T> promise, Runnable afterComplete) Returns a promise that, when it is completed, completes the given promise and then runs the givenRunnable.static <T> Promise.Invocable<T> from(Invocable.InvocationType invocationType, BiConsumer<T, Throwable> consumer) Factory method to create a promise from the given arguments.static <T> Promise.Invocable<T> from(Invocable.InvocationType invocationType, Consumer<T> success, Consumer<Throwable> failure) Factory method to create a promise from the given arguments.static <T> Promise.Invocable<T> noop()static <R> BiConsumer<R, Throwable> toBiConsumer(Promise.Invocable<R> promise) Returns aBiConsumerthat, when it is invoked, completes the given promisestatic <T> CallbacktoCallback(Promise.Invocable<T> promise, T result) Returns a newCallbackthat, when it is completed, completes the given promise.static <W> Promise.Invocable<W> toPromise(CompletableFuture<W> completable) Returns a new promise that, when it is completed, completes the givenCompletableFuture.static <W,T> Promise.Invocable <W> toPromise(Promise.Invocable<T> promise, Function<W, T> mapper) Returns a new promise that, when it is completed, completes the given promise.Methods inherited from interface Invocable
getInvocationType
-
Method Details
-
noop
- Type Parameters:
T- the type of the promise result- Returns:
- a promise that performs no operations.
-
toCallback
Returns a new
Callbackthat, when it is completed, completes the given promise. -
toPromise
Returns a new promise that, when it is completed, completes the given promise.
- Type Parameters:
W- the wrapper typeT- the promise type- Parameters:
promise- the promise to wrapmapper- a function that converts the result type- Returns:
- a new promise wrapping the given promise
-
toPromise
Returns a new promise that, when it is completed, completes the given
CompletableFuture.- Type Parameters:
W- the result type- Parameters:
completable- theCompletableFutureto complete- Returns:
- a new promise
-
toBiConsumer
Returns a
BiConsumerthat, when it is invoked, completes the given promiseTypical usage is with
CompletableFuture.whenComplete(BiConsumer):void example(Promise<T> promise) { CompletableFuture<T> completable = ...; completable.whenComplete(Promise.Invocable.toBiConsumer(promise)); }- Parameters:
promise- the promise to wrap
-
from
static <T> Promise.Invocable<T> from(Invocable.InvocationType invocationType, Consumer<T> success, Consumer<Throwable> failure) Factory method to create a promise from the given arguments.
- Type Parameters:
T- the type of the promise result- Parameters:
invocationType- theInvocable.InvocationTypeof the promisesuccess- the consumer to run upon successfailure- the consumer to run upon failure- Returns:
- a new promise
-
from
static <T> Promise.Invocable<T> from(Invocable.InvocationType invocationType, BiConsumer<T, Throwable> consumer) Factory method to create a promise from the given arguments.
- Type Parameters:
T- the type of the promise result- Parameters:
invocationType- theInvocable.InvocationTypeof the promiseconsumer- the consumer to run upon completion- Returns:
- a new promise
-
from
Returns a promise that, when it is completed, completes the given promise and then runs the given
Runnable.- Type Parameters:
T- the type of the promise result- Parameters:
promise- the promise to wrapafterComplete- theRunnableto run after completion- Returns:
- a new promise wrapping the given promise
- See Also:
-
from
Returns a promise that, when it is completed, runs the given
Runnableand then completes the given promise.- Type Parameters:
T- the type of the promise result- Parameters:
beforeComplete- theRunnableto run before completionpromise- the promise to wrap- Returns:
- a new promise wrapping the given promise
- See Also:
-