org.apache.commons.collections.functors
Class ForClosure
java.lang.Object
org.apache.commons.collections.functors.ForClosure
- Closure, Serializable
public class ForClosure
extends java.lang.Object
Closure implementation that calls another closure n times, like a for loop.
Version:
- Stephen Colebourne
- Commons Collections 3.0
ForClosure
public ForClosure(int count,
Closure closure)
Constructor that performs no validation.
Use getInstance
if you want that.
count
- the number of times to execute the closureclosure
- the closure to execute, not null
execute
public void execute(Object input)
Executes the closure count
times.
- execute in interface Closure
input
- the input object
getClosure
public Closure getClosure()
Gets the closure.
- the closure
- Commons Collections 3.1
getCount
public int getCount()
Gets the count.
- the count
- Commons Collections 3.1
getInstance
public static Closure getInstance(int count,
Closure closure)
Factory method that performs validation.
A null closure or zero count returns the
NOPClosure
.
A count of one returns the specified closure.
count
- the number of times to execute the closureclosure
- the closure to execute, not null
- the
for
closure
Copyright © 2001-2005 Apache Software Foundation. All Rights Reserved.