Package com.symphony.bdk.core.retry
Class RecoveryStrategy
java.lang.Object
com.symphony.bdk.core.retry.RecoveryStrategy
Class used by
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 Summary
ConstructorDescriptionRecoveryStrategy
(Class<? extends T> exceptionType, Predicate<T> condition, ConsumerWithThrowable recovery) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Function to test if an exception corresponds to the recovery strategy.void
Runs the recovery function.
-
Constructor Details
-
RecoveryStrategy
public RecoveryStrategy(Class<? extends T> exceptionType, Predicate<T> condition, ConsumerWithThrowable recovery) - Type Parameters:
T
- the actual exception class- Parameters:
exceptionType
- the actual exception classcondition
- the predicate which checks if a given exception corresponds to the recovery strategyrecovery
- the recovery function to be executed when applicable
-
-
Method Details
-
matches
Function to test if an exception corresponds to the recovery strategy.- Parameters:
e
- the exception to be tested- Returns:
- true if the provided exception corresponds to the recovery strategy
-
runRecovery
Runs the recovery function.- Throws:
Throwable
- can be thrown byConsumerWithThrowable.consume()
-