Interface Fallback<R>
- Type Parameters:
R- result type
- All Superinterfaces:
Policy<R>
- All Known Implementing Classes:
FallbackImpl
A Policy that handles failures using a fallback function or result.
This class is threadsafe.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <R> FallbackBuilder<R> builder(FallbackConfig<R> config) Creates a new FallbackBuilder that will be based on theconfig.static <R> FallbackBuilder<R> builder(CheckedConsumer<ExecutionAttemptedEvent<? extends R>> fallback) Returns thefallbackto be executed if execution fails.static <R> FallbackBuilder<R> builder(CheckedFunction<ExecutionAttemptedEvent<? extends R>, ? extends R> fallback) Returns thefallbackto be executed if execution fails.static <R> FallbackBuilder<R> builder(CheckedRunnable fallback) Returns thefallbackto be executed if execution fails.static <R> FallbackBuilder<R> builder(CheckedSupplier<? extends R> fallback) Returns thefallbackto be executed if execution fails.static <R> FallbackBuilder<R> builder(R fallbackResult) Returns thefallbackResultto be provided if execution fails.static <R> FallbackBuilder<R> builderOfException(CheckedFunction<ExecutionAttemptedEvent<? extends R>, ? extends Exception> fallback) Returns thefallbackto be executed if execution fails and allows an alternative exception to be supplied instead.static <R> FallbackBuilder<R> builderOfStage(CheckedFunction<ExecutionAttemptedEvent<? extends R>, ? extends CompletionStage<R>> fallback) Returns thefallbackto be executed if execution fails.static <R> FallbackBuilder<R> builderOfStage(CheckedSupplier<? extends CompletionStage<R>> fallback) Returns thefallbackto be executed if execution fails.Returns theFallbackConfigthat the Fallback was built with.none()Returns a fallback that will return a null if execution fails.static <R> Fallback<R> of(CheckedConsumer<ExecutionAttemptedEvent<? extends R>> fallback) Returns thefallbackto be executed if execution fails.static <R> Fallback<R> of(CheckedFunction<ExecutionAttemptedEvent<? extends R>, ? extends R> fallback) Returns thefallbackto be executed if execution fails.static <R> Fallback<R> of(CheckedRunnable fallback) Returns thefallbackto be executed if execution fails.static <R> Fallback<R> of(CheckedSupplier<? extends R> fallback) Returns thefallbackto be executed if execution fails.static <R> Fallback<R> of(R fallbackResult) Returns thefallbackResultto be provided if execution fails.static <R> Fallback<R> ofException(CheckedFunction<ExecutionAttemptedEvent<? extends R>, ? extends Exception> fallback) Returns thefallbackto 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 thefallbackto be executed if execution fails.static <R> Fallback<R> ofStage(CheckedSupplier<? extends CompletionStage<R>> fallback) Returns thefallbackto be executed if execution fails.Methods inherited from interface Policy
toExecutor
-
Method Details
-
builder
Creates a new FallbackBuilder that will be based on theconfig. -
builder
Returns thefallbackto be executed if execution fails.- Throws:
NullPointerException- iffallbackis null
-
builder
Returns thefallbackto be executed if execution fails.- Throws:
NullPointerException- iffallbackis null
-
builder
static <R> FallbackBuilder<R> builder(CheckedConsumer<ExecutionAttemptedEvent<? extends R>> fallback) Returns thefallbackto be executed if execution fails. Thefallbackaccepts anExecutionAttemptedEvent.- Throws:
NullPointerException- iffallbackis null
-
builder
static <R> FallbackBuilder<R> builder(CheckedFunction<ExecutionAttemptedEvent<? extends R>, ? extends R> fallback) Returns thefallbackto be executed if execution fails. Thefallbackapplies anExecutionAttemptedEvent.- Throws:
NullPointerException- iffallbackis null
-
builder
Returns thefallbackResultto be provided if execution fails. -
builderOfException
static <R> FallbackBuilder<R> builderOfException(CheckedFunction<ExecutionAttemptedEvent<? extends R>, ? extends Exception> fallback) Returns thefallbackto be executed if execution fails and allows an alternative exception to be supplied instead. Thefallbackapplies anExecutionAttemptedEventand must return an exception.- Throws:
NullPointerException- iffallbackis null
-
builderOfStage
static <R> FallbackBuilder<R> builderOfStage(CheckedSupplier<? extends CompletionStage<R>> fallback) Returns thefallbackto be executed if execution fails.- Throws:
NullPointerException- iffallbackis null
-
builderOfStage
static <R> FallbackBuilder<R> builderOfStage(CheckedFunction<ExecutionAttemptedEvent<? extends R>, ? extends CompletionStage<R>> fallback) Returns thefallbackto be executed if execution fails. Thefallbackaccepts anExecutionAttemptedEvent.- Throws:
NullPointerException- iffallbackis null
-
of
Returns thefallbackto be executed if execution fails.- Throws:
NullPointerException- iffallbackis null
-
of
Returns thefallbackto be executed if execution fails.- Throws:
NullPointerException- iffallbackis null
-
of
Returns thefallbackto be executed if execution fails. Thefallbackaccepts anExecutionAttemptedEvent.- Throws:
NullPointerException- iffallbackis null
-
of
static <R> Fallback<R> of(CheckedFunction<ExecutionAttemptedEvent<? extends R>, ? extends R> fallback) Returns thefallbackto be executed if execution fails. Thefallbackapplies anExecutionAttemptedEvent.- Throws:
NullPointerException- iffallbackis null
-
ofException
static <R> Fallback<R> ofException(CheckedFunction<ExecutionAttemptedEvent<? extends R>, ? extends Exception> fallback) Returns thefallbackto be executed if execution fails and allows an alternative exception to be supplied instead. Thefallbackapplies anExecutionAttemptedEventand must return an exception.- Throws:
NullPointerException- iffallbackis null
-
of
Returns thefallbackResultto be provided if execution fails. -
ofStage
Returns thefallbackto be executed if execution fails.- Throws:
NullPointerException- iffallbackis null
-
ofStage
static <R> Fallback<R> ofStage(CheckedFunction<ExecutionAttemptedEvent<? extends R>, ? extends CompletionStage<R>> fallback) Returns thefallbackto be executed if execution fails. Thefallbackaccepts anExecutionAttemptedEvent.- Throws:
NullPointerException- iffallbackis null
-
none
-
getConfig
FallbackConfig<R> getConfig()Returns theFallbackConfigthat the Fallback was built with.
-