Package io.smallrye.faulttolerance.api
Interface FaultTolerance.Builder.FallbackBuilder<T,R>
-
- Enclosing interface:
- FaultTolerance.Builder<T,R>
public static interface FaultTolerance.Builder.FallbackBuilder<T,R>Configures a fallback.- See Also:
@Fallback
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default FaultTolerance.Builder.FallbackBuilder<T,R>applyOn(Class<? extends Throwable> value)Equivalent toapplyOn(Collections.singleton(value)).FaultTolerance.Builder.FallbackBuilder<T,R>applyOn(Collection<Class<? extends Throwable>> value)Sets the set of exception types considered failure.FaultTolerance.Builder<T,R>done()Returns the original fault tolerance builder.FaultTolerance.Builder.FallbackBuilder<T,R>handler(Function<Throwable,T> value)Sets the fallback handler in the form of aFunctionthat transforms the exception to the fallback value.FaultTolerance.Builder.FallbackBuilder<T,R>handler(Supplier<T> value)Sets the fallback handler in the form of a fallback valueSupplier.default FaultTolerance.Builder.FallbackBuilder<T,R>skipOn(Class<? extends Throwable> value)Equivalent toskipOn(Collections.singleton(value)).FaultTolerance.Builder.FallbackBuilder<T,R>skipOn(Collection<Class<? extends Throwable>> value)Sets the set of exception types considered success.FaultTolerance.Builder.FallbackBuilder<T,R>when(Predicate<Throwable> value)Sets a predicate to determine when an exception should be considered failure and fallback should be applied.default FaultTolerance.Builder.FallbackBuilder<T,R>with(Consumer<FaultTolerance.Builder.FallbackBuilder<T,R>> consumer)
-
-
-
Method Detail
-
handler
FaultTolerance.Builder.FallbackBuilder<T,R> handler(Supplier<T> value)
Sets the fallback handler in the form of a fallback valueSupplier.- Parameters:
value- the fallback value supplier, must not benull- Returns:
- this fallback builder
-
handler
FaultTolerance.Builder.FallbackBuilder<T,R> handler(Function<Throwable,T> value)
Sets the fallback handler in the form of aFunctionthat transforms the exception to the fallback value.- Parameters:
value- the fallback value function, must not benull- Returns:
- this fallback builder
-
applyOn
FaultTolerance.Builder.FallbackBuilder<T,R> applyOn(Collection<Class<? extends Throwable>> value)
Sets the set of exception types considered failure. Defaults to all exceptions (Throwable).- Parameters:
value- collection of exception types, must not benull- Returns:
- this fallback builder
- See Also:
@Fallback.applyOn
-
applyOn
default FaultTolerance.Builder.FallbackBuilder<T,R> applyOn(Class<? extends Throwable> value)
Equivalent toapplyOn(Collections.singleton(value)).- Parameters:
value- an exception class, must not benull- Returns:
- this fallback builder
-
skipOn
FaultTolerance.Builder.FallbackBuilder<T,R> skipOn(Collection<Class<? extends Throwable>> value)
Sets the set of exception types considered success. Defaults to no exception (empty set).- Parameters:
value- collection of exception types, must not benull- Returns:
- this fallback builder
- See Also:
@Fallback.skipOn
-
skipOn
default FaultTolerance.Builder.FallbackBuilder<T,R> skipOn(Class<? extends Throwable> value)
Equivalent toskipOn(Collections.singleton(value)).- Parameters:
value- an exception class, must not benull- Returns:
- this fallback builder
-
when
FaultTolerance.Builder.FallbackBuilder<T,R> when(Predicate<Throwable> value)
Sets a predicate to determine when an exception should be considered failure and fallback should be applied. This is a more general variant ofapplyOn. Note that there is no generalizedskipOn, because all exceptions that do not match this predicate are implicitly considered success.If this method is called,
applyOnandskipOnmay not be called.- Parameters:
value- the predicate, must not benull- Returns:
- this fallback builder
-
done
FaultTolerance.Builder<T,R> done()
Returns the original fault tolerance builder.- Returns:
- the original fault tolerance builder
-
with
default FaultTolerance.Builder.FallbackBuilder<T,R> with(Consumer<FaultTolerance.Builder.FallbackBuilder<T,R>> consumer)
-
-