public class Unreliable extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAILT_RETRIES |
| Constructor and Description |
|---|
Unreliable() |
| Modifier and Type | Method and Description |
|---|---|
static void |
keepTrying(RunnableWithException r)
Performs an action until no exception is thrown.
|
static <T> T |
keepTrying(SupplierWithException<T> s)
Tries to retrieve a value until no exception is thrown.
|
static void |
retryOn(Class exceptionClass,
RunnableWithException r)
Tries to execute the supplied runnable up to three times as long as the specified exception is being thrown.
|
static void |
retryOn(Class exceptionClass,
RunnableWithException r,
int times)
Tries to execute the supplied runnable up to the specified number of times as long as the specified exception is being thrown.
|
static <T> T |
retryOn(Class exceptionClass,
SupplierWithException<T> s)
Tries to retrieve a value up to three times as long as the specified exception is being thrown.
|
static <T> T |
retryOn(Class exceptionClass,
SupplierWithException<T> s,
int times)
Tries to retrieve a value up to the specified number of times as long as the specified exception is being thrown.
|
static void |
retryOn(Collection<Class> exceptionClasses,
RunnableWithException r)
Tries to execute the runnable up to three times as long as one of the specified exceptions is being thrown.
|
static void |
retryOn(Collection<Class> exceptionClasses,
RunnableWithException r,
int times)
Tries to execute the runnable up to the specified number of times as long as one of the specified exceptions is being thrown.
|
static <T> T |
retryOn(Collection<Class> exceptionClasses,
SupplierWithException<T> s)
Tries to retrieve a value up to three times as long as one of the specified exceptions is being thrown.
|
static <T> T |
retryOn(Collection<Class> exceptionClasses,
SupplierWithException<T> s,
int times)
Tries to retrieve a value up to the specified number of times as long as one of the specified exceptions is being thrown.
|
static void |
tenaciously(RunnableWithException r)
Performs an action up to three times until no exception is thrown.
|
static void |
tenaciously(RunnableWithException r,
int times)
Performs an action up to the specified number of times until no exception is thrown.
|
static <T> T |
tenaciously(SupplierWithException<T> s)
Tries to retrieve a value up to three times until no exception is thrown.
|
static <T> T |
tenaciously(SupplierWithException<T> s,
int times)
Tries to retrieve a value up to the specified number of times until no exception is thrown.
|
public static final int DEFAILT_RETRIES
public static void keepTrying(RunnableWithException r)
r - the action to performpublic static <T> T keepTrying(SupplierWithException<T> s)
T - the type of the return values - the function to evaluatepublic static void tenaciously(RunnableWithException r)
r - the action to performRuntimeException - if the action fails three times.public static void tenaciously(RunnableWithException r, int times)
r - the action to performtimes - the number of times to retryRuntimeException - if the action fails the specified number of times.public static <T> T tenaciously(SupplierWithException<T> s)
T - the type of the return values - the function to evaluateRuntimeException - if the function fails three times.public static <T> T tenaciously(SupplierWithException<T> s, int times)
T - the type of the return values - the function to evaluatetimes - the number of times to retryRuntimeException - if the function fails the specified number of times.public static void retryOn(Class exceptionClass, RunnableWithException r)
exceptionClass - retry only on this class of exceptionsr - the function to evaluateRuntimeException - if the function fails the specified number of times or a different exception is thrown.public static <T> T retryOn(Class exceptionClass, SupplierWithException<T> s)
T - the type of the return valueexceptionClass - retry only on this class of exceptionss - the function to evaluateRuntimeException - if the function fails the specified number of times or a different exception is thrown.public static void retryOn(Class exceptionClass, RunnableWithException r, int times)
exceptionClass - retry only on this class of exceptionsr - the function to evaluatetimes - the number of times to retryRuntimeException - if the function fails the specified number of times or a different exception is thrown.public static <T> T retryOn(Class exceptionClass, SupplierWithException<T> s, int times)
T - the type of the return valueexceptionClass - retry only on this class of exceptionss - the function to evaluatetimes - the maximum number of times to retryRuntimeException - if the function fails the specified number of times or a different exception is thrown.public static void retryOn(Collection<Class> exceptionClasses, RunnableWithException r)
exceptionClasses - retry on any of these classes of exceptionsr - the function to evaluateRuntimeException - if the function fails the specified number of times or a different exception is thrown.public static void retryOn(Collection<Class> exceptionClasses, RunnableWithException r, int times)
exceptionClasses - retry on any of these classes of exceptionsr - the function to evaluatetimes - the maximum number of times to retryRuntimeException - if the function fails the specified number of times or a different exception is thrown.public static <T> T retryOn(Collection<Class> exceptionClasses, SupplierWithException<T> s)
T - the type of the return valueexceptionClasses - retry on any of these classes of exceptionss - the function to evaluateRuntimeException - if the function fails the specified number of times or a different exception is thrown.public static <T> T retryOn(Collection<Class> exceptionClasses, SupplierWithException<T> s, int times)
T - the type of the return valueexceptionClasses - retry on any of these classes of exceptionss - the function to evaluatetimes - the maximum number of times to retryRuntimeException - if the function fails the specified number of times or a different exception is thrown.Copyright © 2019. All rights reserved.