Top Constructors Methods
io.github.resilience4j.core

public Class CallableUtils

extends Object
Class Inheritance
Imports
java.util.List, java.util.concurrent.Callable, java.util.function.BiFunction, .Function, .Predicate, .UnaryOperator

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <
return type of callable
T
,
return type of handler
R
>
Callable<R>

Returns:

a function composed of supplier and resultHandler
andThen
(Callable<T>
the callable
callable
,
Function<T, R>
the function applied after callable
resultHandler
)

Returns a composed function that first applies the Callable and then applies the resultHandler.

public static <
return type of callable
T
,
return type of handler
R
>
Callable<R>

Returns:

a function composed of supplier and handler
andThen
(Callable<T>
the callable
callable
,
BiFunction<T, Throwable, R>
the function applied after callable
handler
)

Returns a composed function that first applies the Callable and then applies BiFunction after to the result.

public static <
return type of callable
T
,
return type of resultHandler and exceptionHandler
R
>
Callable<R>

Returns:

a function composed of supplier and handler
andThen
(Callable<T>
the callable
callable
,
Function<T, R>
the function applied after callable was successful
resultHandler
,
Function<Throwable, R>
the function applied after callable has failed
exceptionHandler
)

Returns a composed function that first applies the Callable and then applies either the resultHandler or exceptionHandler.

public static <
return type of after
T
>
Callable<T>

Returns:

a function composed of callable and exceptionHandler
recover
(Callable<T>
the callable which should be recovered from a certain exception
callable
,
Function<Throwable, T>
the exception handler
exceptionHandler
)

Returns a composed function that first executes the Callable and optionally recovers from an exception.

public static <
return type of after
T
>
Callable<T>

Returns:

a function composed of supplier and exceptionHandler
recover
(Callable<T>
the callable
callable
,
Predicate<T>
the result predicate
resultPredicate
,
UnaryOperator<T>
the result handler
resultHandler
)

Returns a composed Callable that first executes the Callable and optionally recovers from a specific result.

public static <
return type of after
T
>
Callable<T>

Returns:

a function composed of supplier and exceptionHandler
recover
(Callable<T>
the callable which should be recovered from a certain exception
callable
,
List<Class<? extends Throwable>>
the specific exception types that should be recovered
exceptionTypes
,
Function<Throwable, T>
the exception handler
exceptionHandler
)

Returns a composed function that first executes the Callable and optionally recovers from an exception.

public static <X extends Throwable,
return type of after
T
>
Callable<T>

Returns:

a function composed of callable and exceptionHandler
recover
(Callable<T>
the callable which should be recovered from a certain exception
callable
,
Class<X>
the specific exception type that should be recovered
exceptionType
,
Function<Throwable, T>
the exception handler
exceptionHandler
)

Returns a composed function that first executes the Callable and optionally recovers from an exception.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

CallableUtilsback to summary
private CallableUtils()

Method Detail

andThenback to summary
public static <T, R> Callable<R> andThen(Callable<T> callable, Function<T, R> resultHandler)

Returns a composed function that first applies the Callable and then applies the resultHandler.

Parameters
<T>
return type of callable
<R>
return type of handler
callable:Callable<T>

the callable

resultHandler:Function<T, R>

the function applied after callable

Returns:Callable<R>

a function composed of supplier and resultHandler

andThenback to summary
public static <T, R> Callable<R> andThen(Callable<T> callable, BiFunction<T, Throwable, R> handler)

Returns a composed function that first applies the Callable and then applies BiFunction after to the result.

Parameters
<T>
return type of callable
<R>
return type of handler
callable:Callable<T>

the callable

handler:BiFunction<T, Throwable, R>

the function applied after callable

Returns:Callable<R>

a function composed of supplier and handler

andThenback to summary
public static <T, R> Callable<R> andThen(Callable<T> callable, Function<T, R> resultHandler, Function<Throwable, R> exceptionHandler)

Returns a composed function that first applies the Callable and then applies either the resultHandler or exceptionHandler.

Parameters
<T>
return type of callable
<R>
return type of resultHandler and exceptionHandler
callable:Callable<T>

the callable

resultHandler:Function<T, R>

the function applied after callable was successful

exceptionHandler:Function<Throwable, R>

the function applied after callable has failed

Returns:Callable<R>

a function composed of supplier and handler

recoverback to summary
public static <T> Callable<T> recover(Callable<T> callable, Function<Throwable, T> exceptionHandler)

Returns a composed function that first executes the Callable and optionally recovers from an exception.

Parameters
<T>
return type of after
callable:Callable<T>

the callable which should be recovered from a certain exception

exceptionHandler:Function<Throwable, T>

the exception handler

Returns:Callable<T>

a function composed of callable and exceptionHandler

recoverback to summary
public static <T> Callable<T> recover(Callable<T> callable, Predicate<T> resultPredicate, UnaryOperator<T> resultHandler)

Returns a composed Callable that first executes the Callable and optionally recovers from a specific result.

Parameters
<T>
return type of after
callable:Callable<T>

the callable

resultPredicate:Predicate<T>

the result predicate

resultHandler:UnaryOperator<T>

the result handler

Returns:Callable<T>

a function composed of supplier and exceptionHandler

recoverback to summary
public static <T> Callable<T> recover(Callable<T> callable, List<Class<? extends Throwable>> exceptionTypes, Function<Throwable, T> exceptionHandler)

Returns a composed function that first executes the Callable and optionally recovers from an exception.

Parameters
<T>
return type of after
callable:Callable<T>

the callable which should be recovered from a certain exception

exceptionTypes:List<Class<? extends Throwable>>

the specific exception types that should be recovered

exceptionHandler:Function<Throwable, T>

the exception handler

Returns:Callable<T>

a function composed of supplier and exceptionHandler

recoverback to summary
public static <X extends Throwable, T> Callable<T> recover(Callable<T> callable, Class<X> exceptionType, Function<Throwable, T> exceptionHandler)

Returns a composed function that first executes the Callable and optionally recovers from an exception.

Parameters
<T>
return type of after
callable:Callable<T>

the callable which should be recovered from a certain exception

exceptionType:Class<X>

the specific exception type that should be recovered

exceptionHandler:Function<Throwable, T>

the exception handler

Returns:Callable<T>

a function composed of callable and exceptionHandler