R - result typepublic class Fallback<R> extends FailurePolicy<Fallback<R>,R>
Note: Fallback extends FailurePolicy PolicyListeners which offer additional configuration.
| Modifier and Type | Field and Description |
|---|---|
static Fallback<Void> |
VOID
A fallback that will return a void result if execution fails.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
isAsync()
Returns whether the Fallback is configured to handle execution results asynchronously, separate from execution..
|
static <R> Fallback<R> |
of(CheckedConsumer<ExecutionAttemptedEvent<? extends R>> fallback)
Returns the
fallback to be executed if execution fails. |
static <R> Fallback<R> |
of(CheckedFunction<ExecutionAttemptedEvent<? extends R>,? extends R> fallback)
Returns the
fallback to be executed if execution fails. |
static <R> Fallback<R> |
of(CheckedRunnable fallback)
Returns the
fallback to be executed if execution fails. |
static <R> Fallback<R> |
of(CheckedSupplier<? extends R> fallback)
Returns the
fallback to be executed if execution fails. |
static <R> Fallback<R> |
of(R fallback)
Returns the
fallback result to be returned if execution fails. |
static <R> Fallback<R> |
ofAsync(CheckedConsumer<ExecutionAttemptedEvent<? extends R>> fallback)
Returns the
fallback to be executed asynchronously if execution fails. |
static <R> Fallback<R> |
ofAsync(CheckedFunction<ExecutionAttemptedEvent<? extends R>,? extends R> fallback)
Returns the
fallback to be executed asynchronously if execution fails. |
static <R> Fallback<R> |
ofAsync(CheckedRunnable fallback)
Returns the
fallback to be executed asynchronously if execution fails. |
static <R> Fallback<R> |
ofAsync(CheckedSupplier<? extends R> fallback)
Returns the
fallback to be executed asynchronously if execution fails. |
static <R> Fallback<R> |
ofException(CheckedFunction<ExecutionAttemptedEvent<? extends R>,? extends Exception> fallback)
Returns the
fallback to be executed if execution fails and allows an alternative exception to be supplied
instead. |
static <R> Fallback<R> |
ofStage(CheckedFunction<ExecutionAttemptedEvent<? extends R>,? extends CompletionStage<R>> fallback)
Returns the
fallback to be executed if execution fails. |
static <R> Fallback<R> |
ofStage(CheckedSupplier<? extends CompletionStage<R>> fallback)
Returns the
fallback to be executed if execution fails. |
static <R> Fallback<R> |
ofStageAsync(CheckedFunction<ExecutionAttemptedEvent<? extends R>,? extends CompletionStage<R>> fallback)
Returns the
fallback to be executed asynchronously if execution fails. |
static <R> Fallback<R> |
ofStageAsync(CheckedSupplier<? extends CompletionStage<R>> fallback)
Returns the
fallback to be executed asynchronously if execution fails. |
Fallback<R> |
onFailedAttempt(CheckedConsumer<? extends ExecutionAttemptedEvent<R>> listener)
Registers the
listener to be called when an execution attempt fails. |
PolicyExecutor |
toExecutor(AbstractExecution execution)
Returns an
PolicyExecutor capable of performing an execution in the context of a Policy and handling
results according to the Policy. |
handle, handle, handle, handleIf, handleIf, handleResult, handleResultIf, isFailureonFailure, onSuccesspublic static <R> Fallback<R> of(CheckedRunnable fallback)
fallback to be executed if execution fails.NullPointerException - if fallback is nullpublic static <R> Fallback<R> of(CheckedSupplier<? extends R> fallback)
fallback to be executed if execution fails.NullPointerException - if fallback is nullpublic static <R> Fallback<R> of(CheckedConsumer<ExecutionAttemptedEvent<? extends R>> fallback)
fallback to be executed if execution fails. The fallback accepts an ExecutionAttemptedEvent.NullPointerException - if fallback is nullpublic static <R> Fallback<R> of(CheckedFunction<ExecutionAttemptedEvent<? extends R>,? extends R> fallback)
fallback to be executed if execution fails. The fallback applies an ExecutionAttemptedEvent.NullPointerException - if fallback is nullpublic static <R> Fallback<R> ofException(CheckedFunction<ExecutionAttemptedEvent<? extends R>,? extends Exception> fallback)
fallback to be executed if execution fails and allows an alternative exception to be supplied
instead. The fallback applies an ExecutionAttemptedEvent and must return an exception.NullPointerException - if fallback is nullpublic static <R> Fallback<R> of(R fallback)
fallback result to be returned if execution fails.public static <R> Fallback<R> ofAsync(CheckedRunnable fallback)
fallback to be executed asynchronously if execution fails.NullPointerException - if fallback is nullpublic static <R> Fallback<R> ofAsync(CheckedSupplier<? extends R> fallback)
fallback to be executed asynchronously if execution fails.NullPointerException - if fallback is nullpublic static <R> Fallback<R> ofAsync(CheckedConsumer<ExecutionAttemptedEvent<? extends R>> fallback)
fallback to be executed asynchronously if execution fails. The fallback accepts an
ExecutionAttemptedEvent.NullPointerException - if fallback is nullpublic static <R> Fallback<R> ofAsync(CheckedFunction<ExecutionAttemptedEvent<? extends R>,? extends R> fallback)
fallback to be executed asynchronously if execution fails. The fallback applies an
ExecutionAttemptedEvent.NullPointerException - if fallback is nullpublic static <R> Fallback<R> ofStage(CheckedSupplier<? extends CompletionStage<R>> fallback)
fallback to be executed if execution fails.NullPointerException - if fallback is nullpublic static <R> Fallback<R> ofStage(CheckedFunction<ExecutionAttemptedEvent<? extends R>,? extends CompletionStage<R>> fallback)
fallback to be executed if execution fails. The fallback accepts an ExecutionAttemptedEvent.NullPointerException - if fallback is nullpublic static <R> Fallback<R> ofStageAsync(CheckedSupplier<? extends CompletionStage<R>> fallback)
fallback to be executed asynchronously if execution fails.NullPointerException - if fallback is nullpublic static <R> Fallback<R> ofStageAsync(CheckedFunction<ExecutionAttemptedEvent<? extends R>,? extends CompletionStage<R>> fallback)
fallback to be executed asynchronously if execution fails. The fallback accepts an
ExecutionAttemptedEvent.NullPointerException - if fallback is nullpublic boolean isAsync()
public Fallback<R> onFailedAttempt(CheckedConsumer<? extends ExecutionAttemptedEvent<R>> listener)
listener to be called when an execution attempt fails. You can also use onFailure to determine when the execution attempt fails and and the fallback
result fails.
Note: Any exceptions that are thrown from within the listener are ignored.
public PolicyExecutor toExecutor(AbstractExecution execution)
PolicyPolicyExecutor capable of performing an execution in the context of a Policy and handling
results according to the Policy.Copyright © 2020. All rights reserved.