public class CallableUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <T,R> java.util.concurrent.Callable<R> |
andThen(java.util.concurrent.Callable<T> callable,
java.util.function.BiFunction<T,java.lang.Throwable,R> handler)
Returns a composed function that first applies the Callable and then applies BiFunction
after to the result. |
static <T,R> java.util.concurrent.Callable<R> |
andThen(java.util.concurrent.Callable<T> callable,
java.util.function.Function<T,R> resultHandler)
Returns a composed function that first applies the Callable and then applies the
resultHandler.
|
static <T,R> java.util.concurrent.Callable<R> |
andThen(java.util.concurrent.Callable<T> callable,
java.util.function.Function<T,R> resultHandler,
java.util.function.Function<java.lang.Throwable,R> exceptionHandler)
Returns a composed function that first applies the Callable and then applies either the
resultHandler or exceptionHandler.
|
static <X extends java.lang.Throwable,T> |
recover(java.util.concurrent.Callable<T> callable,
java.lang.Class<X> exceptionType,
java.util.function.Function<java.lang.Throwable,T> exceptionHandler)
Returns a composed function that first executes the Callable and optionally recovers from an
exception.
|
static <T> java.util.concurrent.Callable<T> |
recover(java.util.concurrent.Callable<T> callable,
java.util.function.Function<java.lang.Throwable,T> exceptionHandler)
Returns a composed function that first executes the Callable and optionally recovers from an
exception.
|
static <T> java.util.concurrent.Callable<T> |
recover(java.util.concurrent.Callable<T> callable,
java.util.List<java.lang.Class<? extends java.lang.Throwable>> exceptionTypes,
java.util.function.Function<java.lang.Throwable,T> exceptionHandler)
Returns a composed function that first executes the Callable and optionally recovers from an
exception.
|
static <T> java.util.concurrent.Callable<T> |
recover(java.util.concurrent.Callable<T> callable,
java.util.function.Predicate<T> resultPredicate,
java.util.function.UnaryOperator<T> resultHandler)
Returns a composed Callable that first executes the Callable and optionally recovers from a specific result.
|
public static <T,R> java.util.concurrent.Callable<R> andThen(java.util.concurrent.Callable<T> callable, java.util.function.Function<T,R> resultHandler)
T
- return type of callableR
- return type of handlercallable
- the callableresultHandler
- the function applied after callablepublic static <T,R> java.util.concurrent.Callable<R> andThen(java.util.concurrent.Callable<T> callable, java.util.function.BiFunction<T,java.lang.Throwable,R> handler)
after
to the result.T
- return type of callableR
- return type of handlercallable
- the callablehandler
- the function applied after callablepublic static <T,R> java.util.concurrent.Callable<R> andThen(java.util.concurrent.Callable<T> callable, java.util.function.Function<T,R> resultHandler, java.util.function.Function<java.lang.Throwable,R> exceptionHandler)
T
- return type of callableR
- return type of resultHandler and exceptionHandlercallable
- the callableresultHandler
- the function applied after callable was successfulexceptionHandler
- the function applied after callable has failedpublic static <T> java.util.concurrent.Callable<T> recover(java.util.concurrent.Callable<T> callable, java.util.function.Function<java.lang.Throwable,T> exceptionHandler)
T
- return type of aftercallable
- the callable which should be recovered from a certain exceptionexceptionHandler
- the exception handlerpublic static <T> java.util.concurrent.Callable<T> recover(java.util.concurrent.Callable<T> callable, java.util.function.Predicate<T> resultPredicate, java.util.function.UnaryOperator<T> resultHandler)
T
- return type of aftercallable
- the callableresultPredicate
- the result predicateresultHandler
- the result handlerpublic static <T> java.util.concurrent.Callable<T> recover(java.util.concurrent.Callable<T> callable, java.util.List<java.lang.Class<? extends java.lang.Throwable>> exceptionTypes, java.util.function.Function<java.lang.Throwable,T> exceptionHandler)
T
- return type of aftercallable
- the callable which should be recovered from a certain exceptionexceptionTypes
- the specific exception types that should be recoveredexceptionHandler
- the exception handlerpublic static <X extends java.lang.Throwable,T> java.util.concurrent.Callable<T> recover(java.util.concurrent.Callable<T> callable, java.lang.Class<X> exceptionType, java.util.function.Function<java.lang.Throwable,T> exceptionHandler)
T
- return type of aftercallable
- the callable which should be recovered from a certain exceptionexceptionType
- the specific exception type that should be recoveredexceptionHandler
- the exception handler