Class Result<T>

java.lang.Object
io.temporal.internal.concurrent.structured.Result<T>
Type Parameters:
T - the success value type

public final class Result<T> extends Object
A settled outcome of a task: SUCCESS, FAILURE, or CANCELLED.

This is the element type returned by TaskScope.awaitAllSettled().

  • Method Details

    • success

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

      public static <T> Result<T> failure(Throwable t)
    • cancelled

      public static <T> Result<T> cancelled()
    • status

      public Result.Status status()
    • isSuccess

      public boolean isSuccess()
    • isFailure

      public boolean isFailure()
    • isCancelled

      public boolean isCancelled()
    • get

      public T get()
      Returns:
      the value on success; otherwise throws IllegalStateException (cause attached).
    • orElse

      public T orElse(T other)
      Returns:
      the value on success, else other.
    • cause

      public Throwable cause()
      Returns:
      the throwable for FAILURE/CANCELLED, or null for SUCCESS.
    • map

      public <R> Result<R> map(Function<? super T,? extends R> fn)
      Maps the success value, leaving FAILURE/CANCELLED untouched.
    • fold

      public <R> R fold(Function<? super T,? extends R> onSuccess, Function<? super Throwable,? extends R> onFailure)
      Collapses both branches into one value. CANCELLED is routed to onFailure.
    • toString

      public String toString()
      Overrides:
      toString in class Object