Package dev.failsafe.spi
Class ExecutionResult<R>
- java.lang.Object
-
- dev.failsafe.spi.ExecutionResult<R>
-
- Type Parameters:
R- result type
public final class ExecutionResult<R> extends java.lang.ObjectThis 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 Summary
Fields Modifier and Type Field Description private booleancompleteWhether a policy has completed handling of the executionprivate longdelayNanosThe amount of time to wait prior to the next execution, according to the policyprivate java.lang.ThrowableexceptionThe execution exception, if anyprivate static ExecutionResult<?>NONEprivate booleannonResultWhether the result represents a non result rather than anullresultprivate static java.util.concurrent.CompletableFuture<?>NULL_FUTUREprivate RresultThe execution result, if anyprivate booleansuccessWhether a policy determined the execution to be a successprivate java.lang.BooleansuccessAllWhether all policies determined the execution to be a success
-
Constructor Summary
Constructors Modifier Constructor Description ExecutionResult(R result, java.lang.Throwable exception)Records an initial execution result withcompletetrue andsuccessset to true ifexceptionis not null.privateExecutionResult(R result, java.lang.Throwable exception, boolean nonResult, long delayNanos, boolean complete, boolean success, java.lang.Boolean successAll)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)static <R> ExecutionResult<R>exception(java.lang.Throwable exception)Returns an ExecutionResult with theexceptionset,completetrue andsuccessfalse.longgetDelay()java.lang.ThrowablegetException()RgetResult()booleangetSuccessAll()Returns whether the execution was successful for all policies.inthashCode()booleanisComplete()booleanisNonResult()booleanisSuccess()static <R> ExecutionResult<R>none()Returns an execution that was completed with a non-result.static <R> java.util.concurrent.CompletableFuture<ExecutionResult<R>>nullFuture()Returns a CompletableFuture that is completed withnull.static <R> ExecutionResult<R>success(R result)Returns an ExecutionResult with theresultset,completetrue andsuccesstrue.java.lang.StringtoString()ExecutionResult<R>with(long delayNanos, boolean complete, boolean success)Returns a copy of the ExecutionResult with thedelayNanos,completeandsuccessvalues.ExecutionResult<R>withDelay(long delayNanos)Returns a copy of the ExecutionResult with thedelayNanosvalue.ExecutionResult<R>withException()Returns a copy of the ExecutionResult with success value of {code false}.ExecutionResult<R>withNonResult()Returns a copy of the ExecutionResult with a non-result, and complete and success set to true.ExecutionResult<R>withNotComplete()Returns a copy of the ExecutionResult withcompleteset to false, else this if nothing has changed.ExecutionResult<R>withResult(R result)Returns a copy of the ExecutionResult with theresultvalue, and complete and success set to true.ExecutionResult<R>withSuccess()Returns a copy of the ExecutionResult with thecompleteandsuccessvalues oftrue.
-
-
-
Field Detail
-
NULL_FUTURE
private static final java.util.concurrent.CompletableFuture<?> NULL_FUTURE
-
NONE
private static final ExecutionResult<?> NONE
-
result
private final R result
The execution result, if any
-
exception
private final java.lang.Throwable exception
The execution exception, if any
-
nonResult
private final boolean nonResult
Whether the result represents a non result rather than anullresult
-
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 java.lang.Boolean successAll
Whether all policies determined the execution to be a success
-
-
Constructor Detail
-
ExecutionResult
public ExecutionResult(R result, java.lang.Throwable exception)
Records an initial execution result withcompletetrue andsuccessset to true ifexceptionis not null.
-
ExecutionResult
private ExecutionResult(R result, java.lang.Throwable exception, boolean nonResult, long delayNanos, boolean complete, boolean success, java.lang.Boolean successAll)
-
-
Method Detail
-
nullFuture
public static <R> java.util.concurrent.CompletableFuture<ExecutionResult<R>> nullFuture()
Returns a CompletableFuture that is completed withnull. Uses an intern'ed value to avoid new object creation.
-
success
public static <R> ExecutionResult<R> success(R result)
Returns an ExecutionResult with theresultset,completetrue andsuccesstrue.
-
exception
public static <R> ExecutionResult<R> exception(java.lang.Throwable exception)
Returns an ExecutionResult with theexceptionset,completetrue andsuccessfalse.
-
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 java.lang.Throwable getException()
-
getDelay
public long getDelay()
-
isComplete
public boolean isComplete()
-
isNonResult
public boolean isNonResult()
-
isSuccess
public boolean isSuccess()
-
withNonResult
public ExecutionResult<R> withNonResult()
-
withResult
public ExecutionResult<R> withResult(R result)
-
withNotComplete
public ExecutionResult<R> withNotComplete()
Returns a copy of the ExecutionResult withcompleteset 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 thecompleteandsuccessvalues oftrue.
-
withDelay
public ExecutionResult<R> withDelay(long delayNanos)
Returns a copy of the ExecutionResult with thedelayNanosvalue.
-
with
public ExecutionResult<R> with(long delayNanos, boolean complete, boolean success)
Returns a copy of the ExecutionResult with thedelayNanos,completeandsuccessvalues.
-
getSuccessAll
public boolean getSuccessAll()
Returns whether the execution was successful for all policies.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-