org.apache.commons.collections.functors
Class IfClosure
java.lang.Object
org.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: 375766 $ $Date: 2006-02-07 23:10:36 +0000 (Tue, 07 Feb 2006) $- Stephen Colebourne
- Matt Benson
IfClosure
public IfClosure(Predicate predicate,
Closure trueClosure)
Constructor that performs no validation.
Use
getInstance
if you want that.
This constructor creates a closure that performs no action when
the predicate is false.
predicate
- predicate to switch on, not nulltrueClosure
- closure used if true, not null
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)
Factory method that performs validation.
This factory creates a closure that performs no action when
the predicate is false.
predicate
- predicate to switch ontrueClosure
- closure used if true
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-2006 Apache Software Foundation. All Rights Reserved.