@API(status=INTERNAL)
public class RecoveryStrategy
extends java.lang.Object
RetryWithRecovery
to store a recovery strategy,
i.e. a condition on the exception to check whether the recovery function must be executed
and a recovery function to be executed.Constructor and Description |
---|
RecoveryStrategy(java.lang.Class<? extends T> exceptionType,
java.util.function.Predicate<T> condition,
ConsumerWithThrowable recovery) |
Modifier and Type | Method and Description |
---|---|
boolean |
matches(java.lang.Exception e)
Function to test if an exception corresponds to the recovery strategy.
|
void |
runRecovery()
Runs the recovery function.
|
public RecoveryStrategy(java.lang.Class<? extends T> exceptionType, java.util.function.Predicate<T> condition, ConsumerWithThrowable recovery)
T
- the actual exception classexceptionType
- the actual exception classcondition
- the predicate which checks if a given exception corresponds to the recovery strategyrecovery
- the recovery function to be executed when applicablepublic boolean matches(java.lang.Exception e)
e
- the exception to be testedpublic void runRecovery() throws java.lang.Throwable
java.lang.Throwable
- can be thrown by ConsumerWithThrowable.consume()