Package: geb.waiting

## [Groovy] Class Wait

- geb.waiting.Wait

- Represents a particular configuration of waiting, but does not encompass what is to be waited on.

  Generally not used by user code, but used internally by Configuration and WaitingSupport.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static Double` | `DEFAULT_RETRY_INTERVAL` | 100 milliseconds
    `static Double` | `DEFAULT_TIMEOUT` | 5 seconds

  - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `String` | `customMessage`
    `boolean` | `includeCauseInExceptionMessage` Whether we should append cause strings to the returned exception message or not
    `Double` | `retryInterval` How many seconds to wait before trying something again while waiting.
    `Double` | `timeout` The maximum amount of seconds that something can be waited on.

  - ### Constructor Summary

    Constructors
    Constructor and description
    `Wait (Double timeout = DEFAULT_TIMEOUT, Double retryInterval = DEFAULT_RETRY_INTERVAL, boolean includeCauseInExceptionMessage = false)`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `Date` | `calculateTimeoutFrom(Date start)`
    `Date` | `calculateTimeoutFromNow()`
    `boolean` | `equals(def other)`
    `int` | `hashCode()`
    `void` | `sleepForRetryInterval()` Blocks the caller for the retryInterval
    `String` | `toString()`
    `T` | `waitFor(Closure<T> block)` Invokes the given `block` every `retryInterval` seconds until it returns a true value according to the Groovy Truth.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Field Detail

    - #### public static final Double DEFAULT_RETRY_INTERVAL

      100 milliseconds

    - #### public static final Double DEFAULT_TIMEOUT

      5 seconds

  - ### Property Detail

    - #### String customMessage

    - #### final boolean includeCauseInExceptionMessage

      Whether we should append cause strings to the returned exception message or not

    - #### final Double retryInterval

      How many seconds to wait before trying something again while waiting.

    - #### final Double timeout

      The maximum amount of seconds that something can be waited on.

  - ### Constructor Detail

    - #### Wait(Double timeout = DEFAULT_TIMEOUT, Double retryInterval = DEFAULT_RETRY_INTERVAL, boolean includeCauseInExceptionMessage = false)

  - ### Method Detail

    - #### Date calculateTimeoutFrom(Date start)

    - #### Date calculateTimeoutFromNow()

    - #### boolean equals(def other)

    - #### int hashCode()

    - #### void sleepForRetryInterval()

      Blocks the caller for the retryInterval

    - #### String toString()

    - #### @SuppressWarnings("UnnecessaryPublicModifier") T waitFor(Closure<T> block)

      Invokes the given `block` every `retryInterval` seconds until it returns a true value according to the Groovy Truth. If `block` does not return a truish value within `timeout` seconds then a WaitTimeoutException will be thrown.

      If the given block is executing at the time when the timeout is reached, it will not be interrupted. This means that this method may take longer than the specified `timeout`. For example, if the `block` takes 5 seconds to complete but the timeout is 2 seconds, the wait is always going to take at least 5 seconds.

      If `block` throws any Throwable, it is treated as a failure and the `block` will be tried again after the `retryInterval` has expired. If the last invocation of `block` throws an exception it will be the cause of the WaitTimeoutException that will be thrown.