Package dev.failsafe.spi
Class ExecutionResult<R>
java.lang.Object
dev.failsafe.spi.ExecutionResult<R>
- Type Parameters:
R
- result type
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
Whether a policy has completed handling of the executionprivate final long
The amount of time to wait prior to the next execution, according to the policyprivate final Throwable
The execution exception, if anyprivate static final ExecutionResult
<?> private final boolean
Whether the result represents a non result rather than anull
resultprivate static final CompletableFuture
<?> private final R
The execution result, if anyprivate final boolean
Whether a policy determined the execution to be a successprivate final Boolean
Whether all policies determined the execution to be a success -
Constructor Summary
ConstructorsModifierConstructorDescriptionExecutionResult
(R result, Throwable exception) Records an initial execution result withcomplete
true andsuccess
set to true ifexception
is not null.private
ExecutionResult
(R result, Throwable exception, boolean nonResult, long delayNanos, boolean complete, boolean success, Boolean successAll) -
Method Summary
Modifier and TypeMethodDescriptionboolean
static <R> ExecutionResult
<R> Returns an ExecutionResult with theexception
set,complete
true andsuccess
false.long
getDelay()
boolean
Returns whether the execution was successful for all policies.int
hashCode()
boolean
boolean
boolean
static <R> ExecutionResult
<R> none()
Returns an execution that was completed with a non-result.static <R> CompletableFuture
<ExecutionResult<R>> Returns a CompletableFuture that is completed withnull
.static <R> ExecutionResult
<R> success
(R result) Returns an ExecutionResult with theresult
set,complete
true andsuccess
true.toString()
with
(long delayNanos, boolean complete, boolean success) Returns a copy of the ExecutionResult with thedelayNanos
,complete
andsuccess
values.withDelay
(long delayNanos) Returns a copy of the ExecutionResult with thedelayNanos
value.Returns a copy of the ExecutionResult with success value of {code false}.Returns a copy of the ExecutionResult with a non-result, and complete and success set to true.Returns a copy of the ExecutionResult withcomplete
set to false, else this if nothing has changed.withResult
(R result) Returns a copy of the ExecutionResult with theresult
value, and complete and success set to true.Returns a copy of the ExecutionResult with thecomplete
andsuccess
values oftrue
.
-
Field Details
-
NULL_FUTURE
-
NONE
-
result
The execution result, if any -
exception
The execution exception, if any -
nonResult
private final boolean nonResultWhether the result represents a non result rather than anull
result -
delayNanos
private final long delayNanosThe amount of time to wait prior to the next execution, according to the policy -
complete
private final boolean completeWhether a policy has completed handling of the execution -
success
private final boolean successWhether a policy determined the execution to be a success -
successAll
Whether all policies determined the execution to be a success
-
-
Constructor Details
-
ExecutionResult
Records an initial execution result withcomplete
true andsuccess
set to true ifexception
is not null. -
ExecutionResult
-
-
Method Details
-
nullFuture
Returns a CompletableFuture that is completed withnull
. Uses an intern'ed value to avoid new object creation. -
success
Returns an ExecutionResult with theresult
set,complete
true andsuccess
true. -
exception
Returns an ExecutionResult with theexception
set,complete
true andsuccess
false. -
none
Returns an execution that was completed with a non-result. Uses an intern'ed value to avoid new object creation. -
getResult
-
getException
-
getDelay
public long getDelay() -
isComplete
public boolean isComplete() -
isNonResult
public boolean isNonResult() -
isSuccess
public boolean isSuccess() -
withNonResult
-
withResult
-
withNotComplete
Returns a copy of the ExecutionResult withcomplete
set to false, else this if nothing has changed. -
withException
Returns a copy of the ExecutionResult with success value of {code false}. -
withSuccess
Returns a copy of the ExecutionResult with thecomplete
andsuccess
values oftrue
. -
withDelay
Returns a copy of the ExecutionResult with thedelayNanos
value. -
with
Returns a copy of the ExecutionResult with thedelayNanos
,complete
andsuccess
values. -
getSuccessAll
public boolean getSuccessAll()Returns whether the execution was successful for all policies. -
toString
-
equals
-
hashCode
public int hashCode()
-