Class LocalHandlerResult
java.lang.Object
io.fluxzero.sdk.tracking.handling.LocalHandlerResult
Result of trying to handle a message locally.
This type preserves a synchronously returned handler value as a direct value instead of wrapping it immediately
in a CompletableFuture. It also distinguishes a handler that returned null from a message for which
no local handler was found.
-
Method Summary
Modifier and TypeMethodDescriptionasFuture()Returns the asynchronous result future, or a completed future containing the stored synchronous value.static LocalHandlerResultasynchronous(CompletableFuture<?> future) Creates a handled result backed by the supplied asynchronous completion.static LocalHandlerResultCreates a successfully completed local result.static LocalHandlerResultCreates a handled result whose future has already failed with the supplied error.getValue()Returns the stored synchronous result, which may be null; asynchronous values are obtained throughasFuture().booleanReturns whether this is a handled synchronous success.booleanReturns whether a local handler accepted the invocation.static LocalHandlerResultReturns the shared result for a message that had no matching local handler.
-
Method Details
-
notHandled
Returns the shared result for a message that had no matching local handler.- Returns:
- a not-handled result
-
completed
Creates a successfully completed local result. The value itself may benull.- Parameters:
value- the value returned by the handler- Returns:
- a synchronously completed result
-
asynchronous
Creates a handled result backed by the supplied asynchronous completion. -
failed
Creates a handled result whose future has already failed with the supplied error. -
isHandled
public boolean isHandled()Returns whether a local handler accepted the invocation. -
isCompletedSuccessfully
public boolean isCompletedSuccessfully()Returns whether this is a handled synchronous success. An asynchronous result remains false even if its future has completed successfully. -
getValue
Returns the stored synchronous result, which may be null; asynchronous values are obtained throughasFuture(). -
asFuture
Returns the asynchronous result future, or a completed future containing the stored synchronous value.
-