Class Waiter

java.lang.Object
dev.comfast.util.waiter.Waiter

public class Waiter extends Object
  • Constructor Details

    • Waiter

      public Waiter(long timeoutMs)
    • Waiter

      public Waiter()
  • Method Details

    • configure

      public Waiter configure(UnaryOperator<WaiterConfig.WaiterConfigBuilder> builderFunc)
      Updates waiter config. Example
      
       waiter.configure(c -> c.description("Custom waiter").timeoutMs(3000))
       
    • waitFor

      public void waitFor(Runnable action)
      Repeat the action till it ends without exception.
      Throws:
      WaitTimeout - with detailed information about Exceptions happen
    • waitFor

      public <T> T waitFor(Supplier<T> action)
      Repeat the action till it ends without exception.
      Returns:
      action result
      Throws:
      WaitTimeout - with detailed information about Exceptions happen
    • waitForValue

      public <T> T waitForValue(Supplier<T> action)
      Repeat the action till it returns truthy value.

      Ignores any Exception during subsequent tries.

      Throws:
      WaitTimeout - with detailed information about Exceptions happen