Class ExecutionResult<R>

java.lang.Object
dev.failsafe.spi.ExecutionResult<R>
Type Parameters:
R - result type

public final class ExecutionResult<R> extends Object
This class represents the internal result of an execution attempt for zero or more policies, before or after the policy has handled the result. If a policy is done handling a result or is no longer able to handle a result, such as when retries are exceeded, the ExecutionResult should be marked as complete.

This class is immutable.

  • Field Details

    • NULL_FUTURE

      private static final CompletableFuture<?> NULL_FUTURE
    • NONE

      private static final ExecutionResult<?> NONE
    • result

      private final R result
      The execution result, if any
    • exception

      private final Throwable exception
      The execution exception, if any
    • nonResult

      private final boolean nonResult
      Whether the result represents a non result rather than a null result
    • delayNanos

      private final long delayNanos
      The amount of time to wait prior to the next execution, according to the policy
    • complete

      private final boolean complete
      Whether a policy has completed handling of the execution
    • success

      private final boolean success
      Whether a policy determined the execution to be a success
    • successAll

      private final Boolean successAll
      Whether all policies determined the execution to be a success
  • Constructor Details

    • ExecutionResult

      public ExecutionResult(R result, Throwable exception)
      Records an initial execution result with complete true and success set to true if exception is not null.
    • ExecutionResult

      private ExecutionResult(R result, Throwable exception, boolean nonResult, long delayNanos, boolean complete, boolean success, Boolean successAll)
  • Method Details

    • nullFuture

      public static <R> CompletableFuture<ExecutionResult<R>> nullFuture()
      Returns a CompletableFuture that is completed with null. Uses an intern'ed value to avoid new object creation.
    • success

      public static <R> ExecutionResult<R> success(R result)
      Returns an ExecutionResult with the result set, complete true and success true.
    • exception

      public static <R> ExecutionResult<R> exception(Throwable exception)
      Returns an ExecutionResult with the exception set, complete true and success false.
    • none

      public static <R> ExecutionResult<R> none()
      Returns an execution that was completed with a non-result. Uses an intern'ed value to avoid new object creation.
    • getResult

      public R getResult()
    • getException

      public Throwable getException()
    • getDelay

      public long getDelay()
    • isComplete

      public boolean isComplete()
    • isNonResult

      public boolean isNonResult()
    • isSuccess

      public boolean isSuccess()
    • withNonResult

      public ExecutionResult<R> withNonResult()
      Returns a copy of the ExecutionResult with a non-result, and complete and success set to true. Returns this if success and result are unchanged.
    • withResult

      public ExecutionResult<R> withResult(R result)
      Returns a copy of the ExecutionResult with the result value, and complete and success set to true. Returns this if success and result are unchanged.
    • withNotComplete

      public ExecutionResult<R> withNotComplete()
      Returns a copy of the ExecutionResult with complete set to false, else this if nothing has changed.
    • withException

      public ExecutionResult<R> withException()
      Returns a copy of the ExecutionResult with success value of {code false}.
    • withSuccess

      public ExecutionResult<R> withSuccess()
      Returns a copy of the ExecutionResult with the complete and success values of true.
    • withDelay

      public ExecutionResult<R> withDelay(long delayNanos)
      Returns a copy of the ExecutionResult with the delayNanos value.
    • with

      public ExecutionResult<R> with(long delayNanos, boolean complete, boolean success)
      Returns a copy of the ExecutionResult with the delayNanos, complete and success values.
    • getSuccessAll

      public boolean getSuccessAll()
      Returns whether the execution was successful for all policies.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object