public interface Callback extends Invocable
A callback abstraction that handles completed/failed events of asynchronous operations.
Semantically this is equivalent to an optimise Promise<Void>, but callback is a more meaningful name than EmptyPromise
Modifier and Type | Interface and Description |
---|---|
static class |
Callback.Completable
A CompletableFuture that is also a Callback.
|
static class |
Callback.Nested |
Invocable.InvocationType
Modifier and Type | Field and Description |
---|---|
static Callback |
NOOP
Instance of Adapter that can be used when the callback methods need an empty
implementation without incurring in the cost of allocating a new Adapter object.
|
__nonBlocking
Modifier and Type | Method and Description |
---|---|
default void |
failed(Throwable x)
Callback invoked when the operation fails.
|
static Callback |
from(CompletableFuture<?> completable)
Creates a non-blocking callback from the given incomplete CompletableFuture.
|
static Callback |
from(CompletableFuture<?> completable,
Invocable.InvocationType invocation)
Creates a callback from the given incomplete CompletableFuture,
with the given
blocking characteristic. |
default void |
succeeded()
Callback invoked when the operation completes.
|
asPreferred, getInvocationType, getInvocationType, invokeNonBlocking, invokePreferNonBlocking, invokePreferred, isNonBlockingInvocation
static final Callback NOOP
default void succeeded()
Callback invoked when the operation completes.
failed(Throwable)
default void failed(Throwable x)
Callback invoked when the operation fails.
x
- the reason for the operation failurestatic Callback from(CompletableFuture<?> completable)
Creates a non-blocking callback from the given incomplete CompletableFuture.
When the callback completes, either succeeding or failing, the
CompletableFuture is also completed, respectively via
CompletableFuture.complete(Object)
or
CompletableFuture.completeExceptionally(Throwable)
.
completable
- the CompletableFuture to convert into a callbackstatic Callback from(CompletableFuture<?> completable, Invocable.InvocationType invocation)
Creates a callback from the given incomplete CompletableFuture,
with the given blocking
characteristic.
completable
- the CompletableFuture to convert into a callbackinvocation
- whether the callback is blockingCopyright © 1995–2017 Webtide. All rights reserved.