Interface Decorators
public interface Decorators
A Decorator builder which can be used to apply multiple decorators to a Supplier, Callable
Function, Runnable, CompletionStage or Consumer.
Decorators are applied in the order of the builder chain. For example, consider:
Supplier<String> supplier = Decorators
.ofSupplier(() -> service.method())
.withCircuitBreaker(CircuitBreaker.ofDefaults("id"))
.withRetry(Retry.ofDefaults("id"))
.withFallback(CallNotPermittedException.class, e -> service.fallbackMethod())
.decorate();
This results in the following composition when executing the supplier: Fallback(Retry(CircuitBreaker(Supplier)))This means the Supplier is called first, then its result is handled by the CircuitBreaker, then Retry and then Fallback. Each Decorator makes its own determination whether an exception represents a failure.
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classDecorators.DecorateCallable<T>static classDecorators.DecorateCheckedFunction<T,R>static classDecorators.DecorateCheckedRunnablestatic classDecorators.DecorateCheckedSupplier<T>static classDecorators.DecorateCompletionStage<T>static classDecorators.DecorateConsumer<T>static classDecorators.DecorateFunction<T,R>static classDecorators.DecorateRunnablestatic classDecorators.DecorateSupplier<T> -
Method Summary
Static Methods Modifier and Type Method Description static <T> Decorators.DecorateCallable<T>ofCallable(java.util.concurrent.Callable<T> callable)static <T, R> Decorators.DecorateCheckedFunction<T,R>ofCheckedFunction(io.vavr.CheckedFunction1<T,R> function)static Decorators.DecorateCheckedRunnableofCheckedRunnable(io.vavr.CheckedRunnable supplier)static <T> Decorators.DecorateCheckedSupplier<T>ofCheckedSupplier(io.vavr.CheckedFunction0<T> supplier)static <T> Decorators.DecorateCompletionStage<T>ofCompletionStage(java.util.function.Supplier<java.util.concurrent.CompletionStage<T>> stageSupplier)static <T> Decorators.DecorateConsumer<T>ofConsumer(java.util.function.Consumer<T> consumer)static <T, R> Decorators.DecorateFunction<T,R>ofFunction(java.util.function.Function<T,R> function)static Decorators.DecorateRunnableofRunnable(java.lang.Runnable runnable)static <T> Decorators.DecorateSupplier<T>ofSupplier(java.util.function.Supplier<T> supplier)
-
Method Details
-
ofSupplier
-
ofFunction
static <T, R> Decorators.DecorateFunction<T,R> ofFunction(java.util.function.Function<T,R> function) -
ofRunnable
-
ofCallable
-
ofCheckedSupplier
static <T> Decorators.DecorateCheckedSupplier<T> ofCheckedSupplier(io.vavr.CheckedFunction0<T> supplier) -
ofCheckedFunction
static <T, R> Decorators.DecorateCheckedFunction<T,R> ofCheckedFunction(io.vavr.CheckedFunction1<T,R> function) -
ofCheckedRunnable
-
ofCompletionStage
static <T> Decorators.DecorateCompletionStage<T> ofCompletionStage(java.util.function.Supplier<java.util.concurrent.CompletionStage<T>> stageSupplier) -
ofConsumer
-