Class 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.
    • 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 class
        RESPONSE - 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 as execute(Supplier, Function, Predicate, boolean) except it returns a Callable that can be invoked later.
        Type Parameters:
        REQUEST - Request object class
        RESPONSE - 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).