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 CompletableFuture
CompletableFuture.AsynchronousCompletionTaskNested classes/interfaces inherited from interface Callback
Callback.CompletableNested classes/interfaces inherited from interface Future
Future.State -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncompose(Consumer<Callback.Completable> consumer) Returns a newCallback.Completablethat, when thisCallback.Completablesucceeds, is passed to the given consumer and then returned.voidMethod to invoke to fail the callback.voidsucceed()Method to invoke to succeed the callback.static Callback.Completablewith(Consumer<Callback.Completable> consumer) Convenience method that creates aCallback.Completablethat is passed to the given consumer and then returned.Methods inherited from class 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, exceptionNow, failedFuture, failedStage, get, get, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, join, minimalCompletionStage, newIncompleteFuture, obtrudeException, obtrudeValue, orTimeout, resultNow, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, runAsync, runAsync, state, supplyAsync, supplyAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, toString, whenComplete, whenCompleteAsync, whenCompleteAsyncMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Callback
asBiConsumer
-
Constructor Details
-
Completable
public Completable()
-
-
Method Details
-
with
Convenience method that creates a
Callback.Completablethat 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
-
fail
-
compose
Returns a new
Callback.Completablethat, when thisCallback.Completablesucceeds, is passed to the given consumer and then returned.If this
Callback.Completablefails, the newCallback.Completableis 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.Completablepassed to the consumer - See Also:
-