org.apache.commons.collections.functors
Class WhileClosure
java.lang.Object
org.apache.commons.collections.functors.WhileClosure
- Closure, Serializable
public class WhileClosure
extends java.lang.Object
Closure implementation that executes a closure repeatedly until a condition is met,
like a do-while or while loop.
$Revision: 1.5 $ $Date: 2004/05/16 11:47:38 $
WhileClosure
public WhileClosure(Predicate predicate,
Closure closure,
boolean doLoop)
Constructor that performs no validation.
Use 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 once
execute
public void execute(Object input)
Executes the closure until the predicate is false.
- execute in interface Closure
getClosure
public Closure getClosure()
Gets the closure.
getInstance
public static Closure getInstance(Predicate predicate,
Closure closure,
boolean doLoop)
Factory method that performs validation.
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
getPredicate
public Predicate getPredicate()
Gets the predicate in use.
isDoLoop
public boolean isDoLoop()
Is the loop a do-while loop.
- true is do-while, false if while
Copyright © 2001-2006 Apache Software Foundation. All Rights Reserved.