Package org.eclipse.jetty.websocket.api
Class Callback.Completable
- All Implemented Interfaces:
CompletionStage<Void>
,Future<Void>
,Callback
- Enclosing interface:
- Callback
A Callback
that is also a CompletableFuture
.
Applications can pass an instance of this class as a Callback
,
but also use the CompletableFuture
APIs.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.CompletableFuture
CompletableFuture.AsynchronousCompletionTask
Nested classes/interfaces inherited from interface org.eclipse.jetty.websocket.api.Callback
Callback.Completable
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncompose
(Consumer<Callback.Completable> consumer) Returns a newCallback.Completable
that, when thisCallback.Completable
succeeds, is passed to the given consumer and then returned.void
Method to invoke to fail the callback.void
succeed()
Method to invoke to succeed the callback.static Callback.Completable
with
(Consumer<Callback.Completable> consumer) Convenience method that creates aCallback.Completable
that is passed to the given consumer and then returned.Methods inherited from class java.util.concurrent.CompletableFuture
acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, cancel, complete, completeAsync, completeAsync, completedFuture, completedStage, completeExceptionally, completeOnTimeout, copy, defaultExecutor, delayedExecutor, delayedExecutor, exceptionally, exceptionallyAsync, exceptionallyAsync, exceptionallyCompose, exceptionallyComposeAsync, exceptionallyComposeAsync, failedFuture, failedStage, get, get, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, join, minimalCompletionStage, newIncompleteFuture, obtrudeException, obtrudeValue, orTimeout, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, runAsync, runAsync, supplyAsync, supplyAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, toString, whenComplete, whenCompleteAsync, whenCompleteAsync
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.websocket.api.Callback
asBiConsumer
-
Constructor Details
-
Completable
public Completable()
-
-
Method Details
-
with
Convenience method that creates a
Callback.Completable
that is passed to the given consumer and then returned.For example:
Completable.with(completable -> session.sendText("TEXT", completable)) .thenRun(session::demand);
- Parameters:
consumer
- the consumer that receives the completable- Returns:
- a new completable passed to the consumer
- See Also:
-
succeed
public void succeed()Description copied from interface:Callback
Method to invoke to succeed the callback.
-
fail
Description copied from interface:Callback
Method to invoke to fail the callback.
-
compose
Returns a new
Callback.Completable
that, when thisCallback.Completable
succeeds, is passed to the given consumer and then returned.If this
Callback.Completable
fails, the newCallback.Completable
is also failed, and the consumer is not invoked.For example:
Callback.Completable.with(completable1 -> session.sendPartialText("hello", false, completable1)) .compose(completable2 -> session.sendPartialText(" ", false, completable2)) .compose(completable3 -> session.sendPartialText("world", true, completable3)) .thenRun(session::demand);
- Parameters:
consumer
- the consumer that receives theCallback.Completable
- Returns:
- a new
Callback.Completable
passed to the consumer - See Also:
-