Class WhileClosure
java.lang.Object
org.apache.commons.collections.functors.WhileClosure
- All Implemented Interfaces:
Serializable
,Closure
@Deprecated(since="2021-04-30")
public class WhileClosure
extends Object
implements Closure, Serializable
Deprecated.
Apache Commons Collections version 3.x is being deprecated from AEMaaCS. The upgraded version 4.4 of Commons Collections is already included as replacement. Customers are advised to upgrade to this version of the library. Please note: the package name was changed to org.apache.commons.collections4. Further note that there are AEM APIs currently exposing the old collections classes; these will be updated in upcoming releases.
Closure implementation that executes a closure repeatedly until a condition is met,
like a do-while or while loop.
WARNING: from v3.2.2 onwards this class will throw an
UnsupportedOperationException
when trying to serialize or
de-serialize an instance to prevent potential remote code execution exploits.
In order to re-enable serialization support for WhileClosure
the following system property can be used (via -Dproperty=true):
org.apache.commons.collections.enableUnsafeSerialization
- Since:
- Commons Collections 3.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionWhileClosure
(Predicate predicate, Closure closure, boolean doLoop) Deprecated.Constructor that performs no validation. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.Executes the closure until the predicate is false.Deprecated.Gets the closure.static Closure
getInstance
(Predicate predicate, Closure closure, boolean doLoop) Deprecated.Factory method that performs validation.Deprecated.Gets the predicate in use.boolean
isDoLoop()
Deprecated.Is the loop a do-while loop.
-
Constructor Details
-
WhileClosure
Deprecated.Constructor that performs no validation. UsegetInstance
if you want that.- Parameters:
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
-
-
Method Details
-
getInstance
Deprecated.Factory method that performs validation.- Parameters:
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- Returns:
- the
while
closure - Throws:
IllegalArgumentException
- if the predicate or closure is null
-
execute
Deprecated.Executes the closure until the predicate is false. -
getPredicate
Deprecated.Gets the predicate in use.- Returns:
- the predicate
- Since:
- Commons Collections 3.1
-
getClosure
Deprecated.Gets the closure.- Returns:
- the closure
- Since:
- Commons Collections 3.1
-
isDoLoop
public boolean isDoLoop()Deprecated.Is the loop a do-while loop.- Returns:
- true is do-while, false if while
- Since:
- Commons Collections 3.1
-