Class TemporalOperationResult<R>

java.lang.Object
io.temporal.nexus.TemporalOperationResult<R>

@Experimental public final class TemporalOperationResult<R> extends Object
Unified result type for Temporal-backed Nexus operations. Encapsulates either a synchronous result or an async operation token.

Use sync(Object) for operations that complete immediately (e.g., signals). Use async(String) for operations that return an operation token for async completion (e.g., start workflow).

  • Method Details

    • sync

      public static <R> TemporalOperationResult<R> sync(@Nullable R value)
      Creates a synchronous result.
      Parameters:
      value - the result value, may be null
      Returns:
      a sync result wrapping the given value
    • async

      public static <R> TemporalOperationResult<R> async(String operationToken)
      Creates an asynchronous result backed by an operation token.
      Parameters:
      operationToken - the operation token identifying the async operation
      Returns:
      an async result wrapping the given token
      Throws:
      IllegalArgumentException - if operationToken is null or empty
    • isSync

      public boolean isSync()
      Returns true if this is a synchronous result.
    • isAsync

      public boolean isAsync()
      Returns true if this is an asynchronous result backed by an operation token.
    • getSyncResult

      @Nullable public R getSyncResult()
      Returns the synchronous result value.
      Returns:
      the sync result value (may be null if the operation produced a null sync value)
      Throws:
      IllegalStateException - if this is an async result; check isSync() first
    • getAsyncOperationToken

      public String getAsyncOperationToken()
      Returns the async operation token.
      Returns:
      the operation token
      Throws:
      IllegalStateException - if this is a sync result; check isAsync() first