Package dev.restate.sdk.common.syscalls
Class Result<T>
- java.lang.Object
-
- dev.restate.sdk.common.syscalls.Result<T>
-
- Type Parameters:
T- result type
public abstract class Result<T> extends java.lang.ObjectResult can be 3 valued:- Empty
- Value
- Failure
Failure in a ready result is always a user failure, and never a syscall failure, as opposed to
SyscallCallback.onCancel(Throwable).
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static <T> Result<T>empty()static <T> Result<T>failure(TerminalException t)abstract @Nullable TerminalExceptiongetFailure()abstract @Nullable TgetValue()abstract booleanisEmpty()abstract booleanisSuccess()<U> Result<U>mapSuccess(java.util.function.Function<T,U> mapper)Map this result success value.static <T> Result<T>success(T value)
-
-
-
Method Detail
-
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(java.util.function.Function<T,U> mapper)
Map this result success value. If the mapper throws an exception, this exception will be converted toTerminalExceptionand return a new failedResult.
-
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)
-
-