Class Result<T>

  • Type Parameters:
    T - result type

    public abstract class Result<T>
    extends java.lang.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 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.
      • 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 to TerminalException and return a new failed Result.
      • empty

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

        public static <T> Result<T> success​(T value)