Package org.awaitility.pollinterval
Class FibonacciPollInterval
java.lang.Object
org.awaitility.pollinterval.FibonacciPollInterval
- All Implemented Interfaces:
PollInterval
Generates a non-linear poll interval based on the fibonacci sequence: [0, 1, 1, 2, 3, 5, 8, 13, ..]
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate final intprivate final TimeUnit -
Constructor Summary
ConstructorsConstructorDescriptionCreate an instance of theFibonacciPollIntervalwith the time unit ofTimeUnit.MILLISECONDS.FibonacciPollInterval(int offset, TimeUnit unit) Create an instance of theFibonacciPollIntervalwith a supplied time unit.Create an instance of theFibonacciPollIntervalwith the supplied time unit starting with offset equal to 0. -
Method Summary
Modifier and TypeMethodDescriptionand()Syntactic sugarbooleanprivate intfib(int value, int current, int previous) static FibonacciPollIntervalSyntactic sugar fornew FibonacciPollInterval()protected intfibonacci(int value) Generate the value of the fibonacci sequence fornumber.static FibonacciPollIntervalSyntactic sugar fornew FibonacciPollInterval(offset, unit)static FibonacciPollIntervalSyntactic sugar fornew FibonacciPollInterval(unit)inthashCode()Generate the next durationoffset(int offset) Create a newFibonacciPollIntervalwith the same time unit but with a different offsettoString()Create a newFibonacciPollIntervalwith the same offset but with a different time unitwith()Syntactic sugar
-
Field Details
-
DEFAULT_OFFSET
private static final int DEFAULT_OFFSET- See Also:
-
unit
-
offset
private final int offset
-
-
Constructor Details
-
FibonacciPollInterval
public FibonacciPollInterval()Create an instance of theFibonacciPollIntervalwith the time unit ofTimeUnit.MILLISECONDS. -
FibonacciPollInterval
Create an instance of theFibonacciPollIntervalwith the supplied time unit starting with offset equal to 0.- Parameters:
unit- The time unit- See Also:
-
FibonacciPollInterval
Create an instance of theFibonacciPollIntervalwith a supplied time unit.- Parameters:
offset- The fibonacci offset. For example if offset is 5 and poll count is 1 then the returned duration will be 8 (sincefib(6)is equal to 8). Default offset is 0. You can set the offset to -1 if you want the first value to befib(0)(i.e. pollCount - offset). By default the first value will befib(1).unit- The time unit
-
-
Method Details
-
next
Generate the next duration- Specified by:
nextin interfacePollInterval- Parameters:
pollCount- The number of times the condition has been polled (evaluated)previousDuration- The duration of the previously returned poll interval- Returns:
- The next duration in the fibonacci sequence.
-
fibonacci
Syntactic sugar fornew FibonacciPollInterval()- Returns:
- A new instance of
FibonacciPollInterval.
-
fibonacci
Syntactic sugar fornew FibonacciPollInterval(unit)- Parameters:
unit- The time unit- Returns:
- A new instance of
FibonacciPollInterval.
-
fibonacci
Syntactic sugar fornew FibonacciPollInterval(offset, unit)- Parameters:
offset- The fibonacci offset. For example if offset is 5 and poll count is 1 then the returned duration will be 8 (sincefib(6)is equal to 8). Default offset is 0.unit- The time unit- Returns:
- A new instance of
FibonacciPollInterval.
-
with
Syntactic sugar- Returns:
- The same of instance of
FibonacciPollInterval
-
and
Syntactic sugar- Returns:
- The same of instance of
FibonacciPollInterval
-
unit
Create a newFibonacciPollIntervalwith the same offset but with a different time unit- Returns:
- The same of instance of
FibonacciPollInterval
-
offset
Create a newFibonacciPollIntervalwith the same time unit but with a different offset- Returns:
- The same of instance of
FibonacciPollInterval
-
fibonacci
protected int fibonacci(int value) Generate the value of the fibonacci sequence fornumber.- Parameters:
value- The value- Returns:
- the fibonacci number
-
fib
private int fib(int value, int current, int previous) -
equals
-
hashCode
public int hashCode() -
toString
-