Package org.awaitility.pollinterval
Class IterativePollInterval
java.lang.Object
org.awaitility.pollinterval.IterativePollInterval
- All Implemented Interfaces:
PollInterval
A poll interval that is generated by a function and a start duration. The function is free to do anything with the duration.
For example:
await().with().pollInterval(iterative(duration -> duration.multiply(2)), Duration.FIVE_HUNDRED_MILLISECONDS).until(..);This generates a poll interval sequence that looks like this (ms): 500, 1000, 2000, 4000, 8000, 16000, ... Note that if the user specifies a poll delay this delay will take place before the first call to
next(int, Duration).-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionIterativePollInterval(Function<Duration, Duration> function) Generate an iterative poll interval based on the supplied function.IterativePollInterval(Function<Duration, Duration> function, Duration startDuration) Generate a iterative poll interval based on the supplied function and start duration.privateIterativePollInterval(Function<Duration, Duration> function, Duration startDuration, boolean startDurationExplicitlyDefined) Generate a iterative poll interval based on the supplied function and start duration. -
Method Summary
Modifier and TypeMethodDescriptionbooleaninthashCode()static IterativePollIntervalSyntactic sugar for creating aIterativePollInterval.static IterativePollIntervalSyntactic sugar for creating aIterativePollInterval.Generate the next Duration based on the supplied function.startDuration(Duration duration) Set the start duration of this poll intervaltoString()with()Syntactic sugar
-
Field Details
-
function
-
startDuration
-
-
Constructor Details
-
IterativePollInterval
Generate an iterative poll interval based on the supplied function.- Parameters:
function- The function to use.
-
IterativePollInterval
Generate a iterative poll interval based on the supplied function and start duration.- Parameters:
function- The function to use.startDuration- The start duration (initial function value)
-
IterativePollInterval
private IterativePollInterval(Function<Duration, Duration> function, Duration startDuration, boolean startDurationExplicitlyDefined) Generate a iterative poll interval based on the supplied function and start duration.- Parameters:
function- The function to use.startDuration- The start duration (initial function value)
-
-
Method Details
-
next
Generate the next Duration based on the supplied function. If you've specified a start duration explicitly then this start duration will override the value ofpreviousDurationwhenpollCountis 1 (i.e. the poll delay).- Specified by:
nextin interfacePollInterval- Parameters:
pollCount- The number of times the condition has been polled (evaluated). Always a positive integer.previousDuration- The duration of the previously returned poll interval.- Returns:
- The duration of the next poll interval
-
iterative
Syntactic sugar for creating aIterativePollInterval.- Parameters:
function- The function to use- Returns:
- A new instance of
IterativePollInterval
-
iterative
public static IterativePollInterval iterative(Function<Duration, Duration> function, Duration startDuration) Syntactic sugar for creating aIterativePollInterval.- Parameters:
function- The function to usestartDuration- The start duration (initial function value)- Returns:
- A new instance of
IterativePollInterval
-
with
Syntactic sugar- Returns:
- The same of instance of
IterativePollInterval
-
startDuration
Set the start duration of this poll interval- Returns:
- A new of instance of
IterativePollIntervalwith the given start duration
-
equals
-
hashCode
public int hashCode() -
toString
-