public class WhileClosure<E> extends Objectimplements Closure <E>
WARNING: from v4.1 onwards this class will not be serializable anymore in order to prevent potential remote code execution exploits. Please refer to COLLECTIONS-580 for more details.
| Constructor and Description |
|---|
WhileClosure(Predicate
Constructor that performs no validation.
|
| Modifier and Type | Method and Description |
|---|---|
void |
execute(E input)
Executes the closure until the predicate is false.
|
Closure |
getClosure()
Gets the closure.
|
Predicate |
getPredicate()
Gets the predicate in use.
|
boolean |
isDoLoop()
Is the loop a do-while loop.
|
static <E> Closure |
whileClosure(Predicate
Factory method that performs validation.
|
public WhileClosure(Predicate<? super E> predicate, Closure <? super E> closure, boolean doLoop)
whileClosure if you want that.
predicate - the predicate used to evaluate when the loop terminates, not null
closure - the closure the execute, not null
doLoop - true to act as a do-while loop, always executing the closure once
public static <E> Closure<E> whileClosure(Predicate <? super E> predicate, Closure <? super E> closure, boolean doLoop)
E - the type that the closure acts on
predicate - the predicate used to evaluate when the loop terminates, not null
closure - the closure the execute, not null
doLoop - true to act as a do-while loop, always executing the closure once
while closure
NullPointerException - if the predicate or closure is null
public void execute(E input)
public Predicate<? super E> getPredicate()
public boolean isDoLoop()