Repeater
instead@Deprecated
public class Repeater
extends java.lang.Object
Closure
s / Callable
-
the first is executed, then the second. If the second closure returns false, the loop
is repeated; if true, it finishes. Further customization can be applied to set the period
between loops and place a maximum limit on how long the loop should run for.
It is configured in a fluent manner. For example, in Groovy:
Repeater.create("Wait until the Frobnitzer is ready")
.repeat {
status = frobnitzer.getStatus()
}
.until {
status == "Ready" || status == "Failed"
}
.limitIterationsTo(30)
.run()
Or in Java:
Repeater.create("Wait until the Frobnitzer is ready")
.until(new Callable<Boolean>() {
public Boolean call() {
String status = frobnitzer.getStatus()
return "Ready".equals(status) || "Failed".equals(status);
}})
.limitIterationsTo(30)
.run()
Constructor and Description |
---|
Repeater()
Deprecated.
|
Repeater(java.util.Map<?,?> flags)
Deprecated.
|
Repeater(java.util.Map<?,?> flags,
java.lang.String description)
Deprecated.
Construct a new instance of Repeater.
|
Repeater(java.lang.String description)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
static Repeater |
create()
Deprecated.
|
static Repeater |
create(java.util.Map<?,?> flags)
Deprecated.
|
static Repeater |
create(java.util.Map<?,?> flags,
java.lang.String description)
Deprecated.
|
static Repeater |
create(java.lang.String description)
Deprecated.
|
Repeater |
every(Duration duration)
Deprecated.
|
Repeater |
every(groovy.time.Duration duration)
Deprecated.
|
Repeater |
every(long duration)
Deprecated.
specify unit
|
Repeater |
every(long period,
java.util.concurrent.TimeUnit unit)
Deprecated.
Set how long to wait between loop iterations.
|
Repeater |
limitIterationsTo(int iterationLimit)
Deprecated.
Set the maximum number of iterations.
|
Repeater |
limitTimeTo(Duration duration)
Deprecated.
|
Repeater |
limitTimeTo(long deadline,
java.util.concurrent.TimeUnit unit)
Deprecated.
Set the amount of time to wait for the condition.
|
Repeater |
repeat()
Deprecated.
Sets the main body of the loop to be a no-op.
|
Repeater |
repeat(java.util.concurrent.Callable<?> body)
Deprecated.
Sets the main body of the loop.
|
Repeater |
repeat(java.lang.Runnable body)
Deprecated.
Sets the main body of the loop.
|
Repeater |
rethrowException()
Deprecated.
If the exit condition check throws an exception, it will be recorded and the last exception will be thrown on failure.
|
Repeater |
rethrowExceptionImmediately()
Deprecated.
If the repeated body or the exit condition check throws an exception, then propagate that exception immediately.
|
boolean |
run()
Deprecated.
Run the loop.
|
void |
setFromFlags(java.util.Map<?,?> flags)
Deprecated.
|
Repeater |
suppressWarnings()
Deprecated.
|
Repeater |
until(java.util.concurrent.Callable<java.lang.Boolean> exitCondition)
Deprecated.
Set code fragment that tests if the loop has completed.
|
public Repeater()
public Repeater(java.util.Map<?,?> flags)
public Repeater(java.lang.String description)
public Repeater(java.util.Map<?,?> flags, java.lang.String description)
flags
- can include period, timeout, descriptiondescription
- a description of the operation that will appear in debug logs.public void setFromFlags(java.util.Map<?,?> flags)
public static Repeater create()
public static Repeater create(java.util.Map<?,?> flags)
public static Repeater create(java.lang.String description)
public static Repeater create(java.util.Map<?,?> flags, java.lang.String description)
public Repeater repeat()
public Repeater repeat(java.lang.Runnable body)
body
- a closure or other Runnable that is executed in the main body of the loop.public Repeater repeat(java.util.concurrent.Callable<?> body)
body
- a closure or other Callable that is executed in the main body of the loop.public Repeater every(long period, java.util.concurrent.TimeUnit unit)
period
- how long to wait between loop iterations.unit
- the unit of measurement of the period.public Repeater every(Duration duration)
every(long, TimeUnit)
public Repeater every(groovy.time.Duration duration)
public Repeater every(long duration)
every(long, TimeUnit)
public Repeater until(java.util.concurrent.Callable<java.lang.Boolean> exitCondition)
exitCondition
- a closure or other Callable that returns a boolean. If this code returns true then the
loop will stop executing.public Repeater rethrowException()
public Repeater rethrowExceptionImmediately()
public Repeater suppressWarnings()
public Repeater limitIterationsTo(int iterationLimit)
iterationLimit
- the maximum number of iterations.public Repeater limitTimeTo(long deadline, java.util.concurrent.TimeUnit unit)
deadline
- the time that the loop should wait.unit
- the unit of measurement of the period.public Repeater limitTimeTo(Duration duration)
limitTimeTo(long, TimeUnit)
public boolean run()