|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.collections.functors.IfClosure
public class IfClosure
Closure implementation acts as an if statement calling one or other closure based on a predicate.
Constructor Summary | |
---|---|
IfClosure(Predicate predicate,
Closure trueClosure)
Constructor that performs no validation. |
|
IfClosure(Predicate predicate,
Closure trueClosure,
Closure falseClosure)
Constructor that performs no validation. |
Method Summary | |
---|---|
void |
execute(java.lang.Object input)
Executes the true or false closure accoring to the result of the predicate. |
Closure |
getFalseClosure()
Gets the closure called when false. |
static Closure |
getInstance(Predicate predicate,
Closure trueClosure)
Factory method that performs validation. |
static Closure |
getInstance(Predicate predicate,
Closure trueClosure,
Closure falseClosure)
Factory method that performs validation. |
Predicate |
getPredicate()
Gets the predicate. |
Closure |
getTrueClosure()
Gets the closure called when true. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public IfClosure(Predicate predicate, Closure trueClosure)
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 nullpublic IfClosure(Predicate predicate, Closure trueClosure, Closure falseClosure)
getInstance
if you want that.
predicate
- predicate to switch on, not nulltrueClosure
- closure used if true, not nullfalseClosure
- closure used if false, not nullMethod Detail |
---|
public static Closure getInstance(Predicate predicate, Closure trueClosure)
This factory creates a closure that performs no action when the predicate is false.
predicate
- predicate to switch ontrueClosure
- closure used if true
if
closure
java.lang.IllegalArgumentException
- if either argument is nullpublic static Closure getInstance(Predicate predicate, Closure trueClosure, Closure falseClosure)
predicate
- predicate to switch ontrueClosure
- closure used if truefalseClosure
- closure used if false
if
closure
java.lang.IllegalArgumentException
- if any argument is nullpublic void execute(java.lang.Object input)
execute
in interface Closure
input
- the input objectpublic Predicate getPredicate()
public Closure getTrueClosure()
public Closure getFalseClosure()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |