Class Result<T>

java.lang.Object
dev.restate.sdk.common.syscalls.Result<T>
Type Parameters:
T - result type

public abstract class Result<T> extends Object
Result can be 3 valued:
  • Empty
  • Value
  • Failure
Empty and Value are used to distinguish the logical empty with the null result.

Failure in a ready result is always a user failure, and never a syscall failure, as opposed to SyscallCallback.onCancel(Throwable).

  • Method Details

    • isSuccess

      public abstract boolean isSuccess()
      Returns:
      true if there is no failure.
    • isEmpty

      public abstract boolean isEmpty()
    • getValue

      public abstract @Nullable T getValue()
      Returns:
      The success value, or null in case is empty.
    • getFailure

      public abstract @Nullable TerminalException getFailure()
    • mapSuccess

      public <U> Result<U> mapSuccess(Function<T,U> mapper)
      Map this result success value. If the mapper throws an exception, this exception will be converted to TerminalException and return a new failed Result.
    • empty

      public static <T> Result<T> empty()
    • success

      public static <T> Result<T> success(T value)
    • failure

      public static <T> Result<T> failure(TerminalException t)