Interface WaiterAcceptor<T>
-
public interface WaiterAcceptor<T>
Inspects the response or errors returned from the operation and determines whether an expected state is met and returns the nextWaiterState
that the waiter should be transitioned to.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static <T> WaiterAcceptor<T>
errorOnExceptionAcceptor(Predicate<Throwable> errorPredicate)
Creates an error waiter acceptor which determines if the exception should transition the waiter to failure statestatic <T> WaiterAcceptor<T>
errorOnResponseAcceptor(Predicate<T> responsePredicate)
Creates a success waiter acceptor which determines if the exception should transition the waiter to success statestatic <T> WaiterAcceptor<T>
errorOnResponseAcceptor(Predicate<T> responsePredicate, String message)
Creates a success waiter acceptor which determines if the exception should transition the waiter to success statedefault boolean
matches(Throwable throwable)
Check to see if the exception matches the expected state defined by this acceptordefault boolean
matches(T response)
Check to see if the response matches with the expected state defined by this acceptordefault Optional<String>
message()
Optional message to provide pertaining to the next WaiterStatestatic <T> WaiterAcceptor<T>
retryOnExceptionAcceptor(Predicate<Throwable> errorPredicate)
Creates a retry on exception waiter acceptor which determines if the exception should transition the waiter to retry statestatic <T> WaiterAcceptor<T>
retryOnResponseAcceptor(Predicate<T> responsePredicate)
Creates a retry on exception waiter acceptor which determines if the exception should transition the waiter to retry statestatic <T> WaiterAcceptor<T>
successOnExceptionAcceptor(Predicate<Throwable> errorPredicate)
Creates an error waiter acceptor which determines if the exception should transition the waiter to success statestatic <T> WaiterAcceptor<T>
successOnResponseAcceptor(Predicate<T> responsePredicate)
Creates a success waiter acceptor which determines if the exception should transition the waiter to success stateWaiterState
waiterState()
-
-
-
Method Detail
-
waiterState
WaiterState waiterState()
- Returns:
- the next
WaiterState
that the waiter should be transitioned to
-
matches
default boolean matches(T response)
Check to see if the response matches with the expected state defined by this acceptor- Parameters:
response
- the response to inspect- Returns:
- whether it accepts the response
-
matches
default boolean matches(Throwable throwable)
Check to see if the exception matches the expected state defined by this acceptor- Parameters:
throwable
- the exception to inspect- Returns:
- whether it accepts the throwable
-
message
default Optional<String> message()
Optional message to provide pertaining to the next WaiterState- Returns:
- the optional message
-
successOnResponseAcceptor
static <T> WaiterAcceptor<T> successOnResponseAcceptor(Predicate<T> responsePredicate)
Creates a success waiter acceptor which determines if the exception should transition the waiter to success state- Type Parameters:
T
- the response type- Parameters:
responsePredicate
- the predicate of the response- Returns:
- a
WaiterAcceptor
-
successOnExceptionAcceptor
static <T> WaiterAcceptor<T> successOnExceptionAcceptor(Predicate<Throwable> errorPredicate)
Creates an error waiter acceptor which determines if the exception should transition the waiter to success state- Type Parameters:
T
- the response type- Parameters:
errorPredicate
- theThrowable
predicate- Returns:
- a
WaiterAcceptor
-
errorOnExceptionAcceptor
static <T> WaiterAcceptor<T> errorOnExceptionAcceptor(Predicate<Throwable> errorPredicate)
Creates an error waiter acceptor which determines if the exception should transition the waiter to failure state- Type Parameters:
T
- the response type- Parameters:
errorPredicate
- theThrowable
predicate- Returns:
- a
WaiterAcceptor
-
errorOnResponseAcceptor
static <T> WaiterAcceptor<T> errorOnResponseAcceptor(Predicate<T> responsePredicate)
Creates a success waiter acceptor which determines if the exception should transition the waiter to success state- Type Parameters:
T
- the response type- Parameters:
responsePredicate
- the predicate of the response- Returns:
- a
WaiterAcceptor
-
errorOnResponseAcceptor
static <T> WaiterAcceptor<T> errorOnResponseAcceptor(Predicate<T> responsePredicate, String message)
Creates a success waiter acceptor which determines if the exception should transition the waiter to success state- Type Parameters:
T
- the response type- Parameters:
responsePredicate
- the predicate of the response- Returns:
- a
WaiterAcceptor
-
retryOnExceptionAcceptor
static <T> WaiterAcceptor<T> retryOnExceptionAcceptor(Predicate<Throwable> errorPredicate)
Creates a retry on exception waiter acceptor which determines if the exception should transition the waiter to retry state- Type Parameters:
T
- the response type- Parameters:
errorPredicate
- theThrowable
predicate- Returns:
- a
WaiterAcceptor
-
retryOnResponseAcceptor
static <T> WaiterAcceptor<T> retryOnResponseAcceptor(Predicate<T> responsePredicate)
Creates a retry on exception waiter acceptor which determines if the exception should transition the waiter to retry state- Type Parameters:
T
- the response type- Parameters:
responsePredicate
- theThrowable
predicate- Returns:
- a
WaiterAcceptor
-
-