Class WhileClosure<T>
java.lang.Object
org.apache.commons.collections4.functors.WhileClosure<T>
- Type Parameters:
- T- the type of the input to the operation.
Closure implementation that executes a closure repeatedly until a condition is met,
 like a do-while or while loop.
 
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.
- Since:
- 3.0
- 
Constructor SummaryConstructorsConstructorDescriptionWhileClosure(Predicate<? super T> predicate, Closure<? super T> closure, boolean doLoop) Constructor that performs no validation.
- 
Method SummaryModifier and TypeMethodDescriptionvoidExecutes the closure until the predicate is false.Gets the closure.Gets the predicate in use.booleanisDoLoop()Is the loop a do-while loop.static <E> Closure<E> whileClosure(Predicate<? super E> predicate, Closure<? super E> closure, boolean doLoop) Factory method that performs validation.
- 
Constructor Details- 
WhileClosureConstructor that performs no validation. UsewhileClosureif you want that.- Parameters:
- predicate- the predicate used to evaluate when the loop terminates, not null
- closure- the closure to execute, not null
- doLoop- true to act as a do-while loop, always executing the closure once
 
 
- 
- 
Method Details- 
whileClosurepublic static <E> Closure<E> whileClosure(Predicate<? super E> predicate, Closure<? super E> closure, boolean doLoop) Factory method that performs validation.- Type Parameters:
- E- the type that the closure acts on
- Parameters:
- predicate- the predicate used to evaluate when the loop terminates, not null
- closure- the closure to execute, not null
- doLoop- true to act as a do-while loop, always executing the closure once
- Returns:
- the whileclosure
- Throws:
- NullPointerException- if the predicate or closure is null
 
- 
execute
- 
getClosure
- 
getPredicateGets the predicate in use.- Returns:
- the predicate
- Since:
- 3.1
 
- 
isDoLoopIs the loop a do-while loop.- Returns:
- true is do-while, false if while
- Since:
- 3.1
 
 
-