|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.collections.functors.WhileClosure
Closure implementation that executes a closure repeatedly until a condition is met, like a do-while or while loop.
Constructor Summary | |
WhileClosure(Predicate predicate,
Closure closure,
boolean doLoop)
Constructor that performs no validation. |
Method Summary | |
void |
execute(Object input)
Executes the closure until the predicate is false. |
Closure |
getClosure()
Gets the closure. |
static Closure |
getInstance(Predicate predicate,
Closure closure,
boolean doLoop)
Factory method that performs validation. |
Predicate |
getPredicate()
Gets the predicate in use. |
boolean |
isDoLoop()
Is the loop a do-while loop. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public WhileClosure(Predicate predicate, Closure closure, boolean doLoop)
getInstance
if you want that.
predicate
- the predicate used to evaluate when the loop terminates, not nullclosure
- the closure the execute, not nulldoLoop
- true to act as a do-while loop, always executing the closure onceMethod Detail |
public static Closure getInstance(Predicate predicate, Closure closure, boolean doLoop)
predicate
- the predicate used to evaluate when the loop terminates, not nullclosure
- the closure the execute, not nulldoLoop
- true to act as a do-while loop, always executing the closure once
while
closure
IllegalArgumentException
- if the predicate or closure is nullpublic void execute(Object input)
execute
in interface Closure
input
- the input objectpublic Predicate getPredicate()
public Closure getClosure()
public boolean isDoLoop()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |