Constructor and Description |
---|
Builder(Callable<V> callable,
BiPredicate<Integer,V> checkResult,
String action)
Constructor of the builder with the required parameters.
|
Modifier and Type | Method and Description |
---|---|
Retrier<V> |
build()
Create a Retrier object with the specification set in this builder.
|
Retrier.Builder<V> |
withAttempts(int attempts)
Set the number of attempts trying to perform the action.
|
Retrier.Builder<V> |
withDelay(long millis)
Set the time in milliseconds to wait for the next attempt.
|
Retrier.Builder<V> |
withDuringActionExceptionListener(BiFunction<Integer,Exception,V> exceptionListener)
Set the listener to be executed when an allowed exception is raised when performing the action.
|
Retrier.Builder<V> |
withDuringActionExceptions(Class<?>[] exceptions)
Set all the exceptions that are allowed and indicate that the action was failed.
|
public Builder(@NonNull Callable<V> callable, @NonNull BiPredicate<Integer,V> checkResult, @NonNull String action)
callable
- Action to performcheckResult
- Method to check if the result of the action was a successaction
- name of the action to perform, for messages purposes.@NonNull public Retrier.Builder<V> withAttempts(int attempts)
attempts
- number of attempts@NonNull public Retrier.Builder<V> withDelay(long millis)
millis
- milliseconds to wait@NonNull public Retrier.Builder<V> withDuringActionExceptions(@CheckForNull Class<?>[] exceptions)
withDuringActionExceptionListener(BiFunction)
).
In any case, the retrier continues its process, retrying to perform the action again, as it was a normal failure.exceptions
- exceptions that indicate that the action was failed.@NonNull public Retrier.Builder<V> withDuringActionExceptionListener(@NonNull BiFunction<Integer,Exception,V> exceptionListener)
exceptionListener
- the listener to call toCopyright © 2004–2021. All rights reserved.