public class IfClosure extends java.lang.Object implements Closure, java.io.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(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.
|
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
closurejava.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 falseif
closurejava.lang.IllegalArgumentException
- if any argument is nullpublic void execute(java.lang.Object input)
public Predicate getPredicate()
public Closure getTrueClosure()
public Closure getFalseClosure()
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"