Package dev.failsafe.internal
Class FallbackImpl<R>
- java.lang.Object
-
- dev.failsafe.internal.FallbackImpl<R>
-
- Type Parameters:
R
- result type
- All Implemented Interfaces:
Fallback<R>
,Policy<R>
,FailurePolicy<R>
public class FallbackImpl<R> extends java.lang.Object implements Fallback<R>, FailurePolicy<R>
AFallback
implementation.- See Also:
FallbackBuilder
-
-
Field Summary
Fields Modifier and Type Field Description private FallbackConfig<R>
config
static Fallback<java.lang.Void>
NONE
A fallback that will return null if execution fails.
-
Constructor Summary
Constructors Constructor Description FallbackImpl(FallbackConfig<R> config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected R
apply(R result, java.lang.Throwable exception, ExecutionContext<R> context)
Returns the applied fallback result.protected java.util.concurrent.CompletableFuture<R>
applyStage(R result, java.lang.Throwable exception, ExecutionContext<R> context)
Returns a future applied fallback result.FallbackConfig<R>
getConfig()
Returns theFallbackConfig
that the Fallback was built with.PolicyExecutor<R>
toExecutor(int policyIndex)
Returns aPolicyExecutor
capable of handling an execution for the Policy.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface dev.failsafe.spi.FailurePolicy
isFailure
-
-
-
-
Field Detail
-
NONE
public static Fallback<java.lang.Void> NONE
A fallback that will return null if execution fails.
-
config
private final FallbackConfig<R> config
-
-
Constructor Detail
-
FallbackImpl
public FallbackImpl(FallbackConfig<R> config)
-
-
Method Detail
-
getConfig
public FallbackConfig<R> getConfig()
Description copied from interface:Fallback
Returns theFallbackConfig
that the Fallback was built with.
-
apply
protected R apply(R result, java.lang.Throwable exception, ExecutionContext<R> context) throws java.lang.Throwable
Returns the applied fallback result.- Throws:
java.lang.Throwable
-
applyStage
protected java.util.concurrent.CompletableFuture<R> applyStage(R result, java.lang.Throwable exception, ExecutionContext<R> context) throws java.lang.Throwable
Returns a future applied fallback result.- Throws:
java.lang.Throwable
-
toExecutor
public PolicyExecutor<R> toExecutor(int policyIndex)
Description copied from interface:Policy
Returns aPolicyExecutor
capable of handling an execution for the Policy.- Specified by:
toExecutor
in interfacePolicy<R>
-
-