|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.collections.functors.WhileClosure<T>
public class WhileClosure<T>
Closure implementation that executes a closure repeatedly until a condition is met, like a do-while or while loop.
Constructor Summary | |
---|---|
WhileClosure(Predicate<? super T> predicate,
Closure<? super T> closure,
boolean doLoop)
Constructor that performs no validation. |
Method Summary | ||
---|---|---|
void |
execute(T input)
Executes the closure until the predicate is false. |
|
Closure<? super T> |
getClosure()
Gets the closure. |
|
static
|
getInstance(Predicate<? super T> predicate,
Closure<? super T> closure,
boolean doLoop)
Factory method that performs validation. |
|
Predicate<? super T> |
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<? super T> predicate, Closure<? super T> 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 <T> Closure<T> getInstance(Predicate<? super T> predicate, Closure<? super T> 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(T input)
execute
in interface Closure<T>
input
- the input objectpublic Predicate<? super T> getPredicate()
public Closure<? super T> getClosure()
public boolean isDoLoop()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |