public class IfClosure<E> extends Objectimplements Closure <E>, Serializable
| Constructor and Description |
|---|
IfClosure(Predicate
Constructor that performs no validation.
|
IfClosure(Predicate
Constructor that performs no validation.
|
| Modifier and Type | Method and Description |
|---|---|
void |
execute(E input)
Executes the true or false closure according to the result of the predicate.
|
Closure |
getFalseClosure()
Gets the closure called when false.
|
Predicate |
getPredicate()
Gets the predicate.
|
Closure |
getTrueClosure()
Gets the closure called when true.
|
static <E> Closure |
ifClosure(Predicate
Factory method that performs validation.
|
static <E> Closure |
ifClosure(Predicate
Factory method that performs validation.
|
public IfClosure(Predicate<? super E> predicate, Closure <? super E> trueClosure)
ifClosure if you want that.
This constructor creates a closure that performs no action when the predicate is false.
predicate - predicate to switch on, not null
trueClosure - closure used if true, not null
public IfClosure(Predicate<? super E> predicate, Closure <? super E> trueClosure, Closure <? super E> falseClosure)
ifClosure if you want that.
predicate - predicate to switch on, not null
trueClosure - closure used if true, not null
falseClosure - closure used if false, not null
public static <E> Closure<E> ifClosure(Predicate <? super E> predicate, Closure <? super E> trueClosure)
This factory creates a closure that performs no action when the predicate is false.
E - the type that the closure acts on
predicate - predicate to switch on
trueClosure - closure used if true
if closure
NullPointerException - if either argument is null
public static <E> Closure<E> ifClosure(Predicate <? super E> predicate, Closure <? super E> trueClosure, Closure <? super E> falseClosure)
E - the type that the closure acts on
predicate - predicate to switch on
trueClosure - closure used if true
falseClosure - closure used if false
if closure
NullPointerException - if any argument is null
public void execute(E input)
public Predicate<? super E> getPredicate()
public Closure<? super E> getTrueClosure()