org.apache.commons.collections.functors
Class IfClosure
java.lang.Objectorg.apache.commons.collections.functors.IfClosure
- Closure, Serializable
public class IfClosure
extends java.lang.Object
Closure implementation acts as an if statement calling one or other closure
based on a predicate.
$Revision: 1.6 $ $Date: 2004/05/16 11:47:38 $
IfClosure
public IfClosure(Predicate predicate,
Closure trueClosure,
Closure falseClosure) Constructor that performs no validation.
Use getInstance if you want that.
predicate - predicate to switch on, not nulltrueClosure - closure used if true, not nullfalseClosure - closure used if false, not null
execute
public void execute(Object input)
Executes the true or false closure accoring to the result of the predicate.
- execute in interface Closure
getFalseClosure
public Closure getFalseClosure()
Gets the closure called when false.
getInstance
public static Closure getInstance(Predicate predicate,
Closure trueClosure,
Closure falseClosure) Factory method that performs validation.
predicate - predicate to switch ontrueClosure - closure used if truefalseClosure - closure used if false
getPredicate
public Predicate getPredicate()
Gets the predicate.
getTrueClosure
public Closure getTrueClosure()
Gets the closure called when true.
Copyright © 2001-2007 Apache Software Foundation. All Rights Reserved.