Class ForClosure<T>
java.lang.Object
org.apache.commons.collections4.functors.ForClosure<T>
- Type Parameters:
T- the type of the input to the operation.
Closure implementation that calls another closure n times, like a for 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 Summary
ConstructorsConstructorDescriptionForClosure(int count, Closure<? super T> closure) Constructor that performs no validation. -
Method Summary
Modifier and TypeMethodDescriptionvoidExecutes the closurecounttimes.static <E> Closure<E> forClosure(int count, Closure<? super E> closure) Factory method that performs validation.Gets the closure.intgetCount()Gets the count.
-
Constructor Details
-
ForClosure
Constructor that performs no validation. UseforClosureif you want that.- Parameters:
count- the number of times to execute the closureclosure- the closure to execute, not null
-
-
Method Details
-
forClosure
Factory method that performs validation.A null closure or zero count returns the
NOPClosure. A count of one returns the specified closure.- Type Parameters:
E- the type that the closure acts on- Parameters:
count- the number of times to execute the closureclosure- the closure to execute, not null- Returns:
- the
forclosure
-
execute
-
getClosure
-
getCount
-