S - self typeC - config typeR - result typepublic abstract class FailurePolicyBuilder<S,C extends FailurePolicyConfig<R>,R> extends PolicyBuilder<S,C,R>
handle conditions. The default exception handling condition will only be overridden by
another condition that handles failure exceptions such as handle(Class) or handleIf(CheckedBiPredicate).
Specifying a condition that only handles results, such as handleResult(Object) or
handleResultIf(CheckedPredicate) will not replace the default exception handling condition.handle conditions are specified, any condition that matches an execution result or exception
will trigger policy handling.config| Modifier | Constructor and Description |
|---|---|
protected |
FailurePolicyBuilder(C config) |
| Modifier and Type | Method and Description |
|---|---|
S |
handle(Class<? extends Throwable>... exceptions)
Specifies the exceptions to handle as failures.
|
S |
handle(Class<? extends Throwable> exception)
Specifies the exception to handle as a failure.
|
S |
handle(List<Class<? extends Throwable>> exceptions)
Specifies the exceptions to handle as failures.
|
S |
handleIf(CheckedBiPredicate<R,? extends Throwable> resultPredicate)
Specifies that a failure has occurred if the
resultPredicate matches the execution result. |
S |
handleIf(CheckedPredicate<? extends Throwable> failurePredicate)
Specifies that a failure has occurred if the
failurePredicate matches the exception. |
S |
handleResult(R result)
Specifies that a failure has occurred if the
result matches the execution result. |
S |
handleResultIf(CheckedPredicate<R> resultPredicate)
Specifies that a failure has occurred if the
resultPredicate matches the execution result. |
onFailure, onSuccessprotected FailurePolicyBuilder(C config)
public S handle(Class<? extends Throwable> exception)
exception will be
handled.NullPointerException - if exception is null@SafeVarargs public final S handle(Class<? extends Throwable>... exceptions)
exceptions will
be handled.NullPointerException - if exceptions is nullIllegalArgumentException - if exceptions is emptypublic S handle(List<Class<? extends Throwable>> exceptions)
exceptions will
be handled.NullPointerException - if exceptions is nullIllegalArgumentException - if exceptions is null or emptypublic S handleIf(CheckedPredicate<? extends Throwable> failurePredicate)
failurePredicate matches the exception. Any exception thrown
from the failurePredicate is treated as a false result.NullPointerException - if failurePredicate is nullpublic S handleIf(CheckedBiPredicate<R,? extends Throwable> resultPredicate)
resultPredicate matches the execution result. Any exception
thrown from the resultPredicate is treated as a false result.NullPointerException - if resultPredicate is nullpublic S handleResult(R result)
result matches the execution result. This method is only
considered when a result is returned from an execution, not when an exception is thrown.public S handleResultIf(CheckedPredicate<R> resultPredicate)
resultPredicate matches the execution result. This method is
only considered when a result is returned from an execution, not when an exception is thrown. To handle results or
exceptions with the same condition, use handleIf(CheckedBiPredicate). Any exception thrown from the resultPredicate is treated as a false result.NullPointerException - if resultPredicate is nullCopyright © 2022. All rights reserved.