|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.collections4.functors.WhileClosure<E>
public class WhileClosure<E>
Closure implementation that executes a closure repeatedly until a condition is met, like a do-while or while loop.
Constructor Summary | |
---|---|
WhileClosure(Predicate<? super E> predicate,
Closure<? super E> closure,
boolean doLoop)
Constructor that performs no validation. |
Method Summary | ||
---|---|---|
void |
execute(E input)
Executes the closure until the predicate is false. |
|
Closure<? super E> |
getClosure()
Gets the closure. |
|
Predicate<? super E> |
getPredicate()
Gets the predicate in use. |
|
boolean |
isDoLoop()
Is the loop a do-while loop. |
|
static
|
whileClosure(Predicate<? super E> predicate,
Closure<? super E> closure,
boolean doLoop)
Factory method that performs validation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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 nullclosure
- the closure the execute, not nulldoLoop
- true to act as a do-while loop, always executing the closure onceMethod Detail |
---|
public static <E> Closure<E> whileClosure(Predicate<? super E> predicate, Closure<? super E> closure, boolean doLoop)
E
- the type that the closure acts onpredicate
- 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(E input)
execute
in interface Closure<E>
input
- the input objectpublic Predicate<? super E> getPredicate()
public Closure<? super E> getClosure()
public boolean isDoLoop()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |