public class WhileClosure<E> extends Object implements Closure<E>
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.
Constructor and Description |
---|
WhileClosure(Predicate<? super E> predicate,
Closure<? super E> closure,
boolean doLoop)
Constructor that performs no validation.
|
Modifier and Type | Method and Description |
---|---|
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 <E> Closure<E> |
whileClosure(Predicate<? super E> predicate,
Closure<? super E> closure,
boolean doLoop)
Factory method that performs validation.
|
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 oncepublic 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 oncewhile
closureNullPointerException
- if the predicate or closure is nullpublic Predicate<? super E> getPredicate()
public Closure<? super E> getClosure()
public boolean isDoLoop()
Copyright © 2001–2018 The Apache Software Foundation. All rights reserved.