R - result typepublic class Fallback<R> extends FailurePolicy<Fallback<R>,R>
Note: Fallback extends FailurePolicy which offers additional configuration.
| Modifier and Type | Method and Description |
|---|---|
R |
apply(R result,
Throwable failure,
ExecutionContext context) |
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. |
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 R apply(R result, Throwable failure, ExecutionContext context) throws Exception
Exceptionpublic boolean isAsync()
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 © 2019. All rights reserved.