Interface Decorators
-
public interface DecoratorsA 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:
This results in the following composition when executing the supplier:Supplier<String> supplier = Decorators .ofSupplier(() -> service.method()) .withCircuitBreaker(CircuitBreaker.ofDefaults("id")) .withRetry(Retry.ofDefaults("id")) .withFallback(CallNotPermittedException.class, e -> service.fallbackMethod()) .decorate();
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 Detail
-
ofSupplier
static <T> Decorators.DecorateSupplier<T> ofSupplier(java.util.function.Supplier<T> supplier)
-
ofFunction
static <T,R> Decorators.DecorateFunction<T,R> ofFunction(java.util.function.Function<T,R> function)
-
ofRunnable
static Decorators.DecorateRunnable ofRunnable(java.lang.Runnable runnable)
-
ofCallable
static <T> Decorators.DecorateCallable<T> ofCallable(java.util.concurrent.Callable<T> callable)
-
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
static Decorators.DecorateCheckedRunnable ofCheckedRunnable(io.vavr.CheckedRunnable supplier)
-
ofCompletionStage
static <T> Decorators.DecorateCompletionStage<T> ofCompletionStage(java.util.function.Supplier<java.util.concurrent.CompletionStage<T>> stageSupplier)
-
ofConsumer
static <T> Decorators.DecorateConsumer<T> ofConsumer(java.util.function.Consumer<T> consumer)
-
-