Class LocalHandlerResult

java.lang.Object
io.fluxzero.sdk.tracking.handling.LocalHandlerResult

public final class LocalHandlerResult extends Object
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 Details

    • notHandled

      public static LocalHandlerResult notHandled()
      Returns the shared result for a message that had no matching local handler.
      Returns:
      a not-handled result
    • completed

      public static LocalHandlerResult completed(Object value)
      Creates a successfully completed local result. The value itself may be null.
      Parameters:
      value - the value returned by the handler
      Returns:
      a synchronously completed result
    • asynchronous

      public static LocalHandlerResult asynchronous(CompletableFuture<?> future)
      Creates a handled result backed by the supplied asynchronous completion.
    • failed

      public static LocalHandlerResult failed(Throwable error)
      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

      public Object getValue()
      Returns the stored synchronous result, which may be null; asynchronous values are obtained through asFuture().
    • asFuture

      public CompletableFuture<Object> asFuture()
      Returns the asynchronous result future, or a completed future containing the stored synchronous value.