Package com.oracle.bmc.waiter
Class BmcGenericWaiter
- java.lang.Object
-
- com.oracle.bmc.waiter.BmcGenericWaiter
-
public class BmcGenericWaiter extends Object
BmcGenericWaiter is a Waiter that provides a generic foundation to build more custom waiters for specific types of calls.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BmcGenericWaiter.WaitConditionFailedException
Exception indicating the the condition being waited on was not met before the termination condition was satisfied.
-
Constructor Summary
Constructors Constructor Description BmcGenericWaiter(TerminationStrategy terminationStrategy, DelayStrategy delayStrategy)
Creates a new waiter with the given strategies.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <REQUEST,RESPONSE>
RESPONSEexecute(Supplier<REQUEST> requestSupplier, Function<REQUEST,RESPONSE> functionCall, Predicate<RESPONSE> terminationPredicate, boolean allow404)
Blocks until a specific condition is met.<REQUEST,RESPONSE>
Callable<RESPONSE>toCallable(Supplier<REQUEST> requestSupplier, Function<REQUEST,RESPONSE> functionCall, Predicate<RESPONSE> terminationPredicate, boolean allow404)
Same asexecute(Supplier, Function, Predicate, boolean)
except it returns aCallable
that can be invoked later.
-
-
-
Constructor Detail
-
BmcGenericWaiter
public BmcGenericWaiter(TerminationStrategy terminationStrategy, DelayStrategy delayStrategy)
Creates a new waiter with the given strategies.- Parameters:
terminationStrategy
- The termination strategy to use.delayStrategy
- The delay strategy to use.
-
-
Method Detail
-
execute
public <REQUEST,RESPONSE> RESPONSE execute(Supplier<REQUEST> requestSupplier, Function<REQUEST,RESPONSE> functionCall, Predicate<RESPONSE> terminationPredicate, boolean allow404) throws BmcGenericWaiter.WaitConditionFailedException
Blocks until a specific condition is met.If the
allow404
param is set to true, the waiter will return null if the request fails with a 404 exception.- Type Parameters:
REQUEST
- Request object classRESPONSE
- Response object class- Parameters:
requestSupplier
- Supplier that provides a new request instance to fetch the current state.functionCall
- Function that will be invoked to fetch the current state. It will be provided the request instance given by the requestSupplier.terminationPredicate
- The termination predicate that will inspect the current state (returned response instance) to determine if it is done waiting.allow404
- True to allow 404 responses to be accepted (ex, for termination conditions).- Returns:
- The last response object that was received and was accepted by the termination predicate (or null if 404 was allowed).
- Throws:
BmcGenericWaiter.WaitConditionFailedException
- If the termination condition was not met.
-
toCallable
public <REQUEST,RESPONSE> Callable<RESPONSE> toCallable(Supplier<REQUEST> requestSupplier, Function<REQUEST,RESPONSE> functionCall, Predicate<RESPONSE> terminationPredicate, boolean allow404)
Same asexecute(Supplier, Function, Predicate, boolean)
except it returns aCallable
that can be invoked later.- Type Parameters:
REQUEST
- Request object classRESPONSE
- Response object class- Parameters:
requestSupplier
- Supplier that provides a new request instance to fetch the current state.functionCall
- Function that will be invoked to fetch the current state. It will be provided the request instance given by the requestSupplier.terminationPredicate
- The termination predicate that will inspect the current state (returned response instance) to determine if it is done waiting.allow404
- True to allow 404 responses to be accepted (ex, for termination conditions).- Returns:
- The last response object that was received and was accepted by the termination predicate (or null if 404 was allowed).
-
-