public class IfClosure extends Object implements Closure, Serializable
Constructor and Description |
---|
IfClosure(Predicate predicate,
Closure trueClosure)
Constructor that performs no validation.
|
IfClosure(Predicate predicate,
Closure trueClosure,
Closure falseClosure)
Constructor that performs no validation.
|
Modifier and Type | Method and Description |
---|---|
void |
execute(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.
|
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 nullpublic 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 trueif
closureIllegalArgumentException
- 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 falseif
closureIllegalArgumentException
- if any argument is nullpublic void execute(Object input)
public Predicate getPredicate()
public Closure getTrueClosure()
public Closure getFalseClosure()
Copyright © 2001–2015 The Apache Software Foundation. All rights reserved.