Package org.eclipse.jetty.websocket.api
Interface Callback
- All Known Implementing Classes:
Callback.Completable
public interface Callback
A callback object that handles success/failure events of asynchronous operations.
NOTE: This interface is almost identical to org.eclipse.jetty.util.Callback
,
which however cannot be used in the Jetty WebSocket APIs for web application classloading
reasons.
-
Nested Class Summary
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiondefault BiConsumer<? super Void,
? super Throwable> Converts this callback into aBiConsumer
that can be passed toCompletableFuture.whenComplete(BiConsumer)
.default void
Method to invoke to fail the callback.static Callback
Creates a callback from the given success and failure lambdas.default void
succeed()
Method to invoke to succeed the callback.
-
Field Details
-
NOOP
Empty implementation.
-
-
Method Details
-
from
Creates a callback from the given success and failure lambdas.
- Parameters:
success
- the success action to invoke when the callback succeedsfailure
- the failure consumer to invoke when the callback fails- Returns:
- a new callback
-
succeed
default void succeed()Method to invoke to succeed the callback.
- See Also:
-
fail
Method to invoke to fail the callback.
- Parameters:
x
- the failure
-
asBiConsumer
Converts this callback into a
BiConsumer
that can be passed toCompletableFuture.whenComplete(BiConsumer)
.When the
BiConsumer
is accepted, this callback is completed.- Returns:
- a
BiConsumer
that completes this callback - See Also:
-