public class IfClosure<E> extends java.lang.Object implements Closure<E>, java.io.Serializable
Constructor and Description |
---|
IfClosure(Predicate<? super E> predicate,
Closure<? super E> trueClosure)
Constructor that performs no validation.
|
IfClosure(Predicate<? super E> predicate,
Closure<? super E> trueClosure,
Closure<? super E> falseClosure)
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<? super E> |
getFalseClosure()
Gets the closure called when false.
|
Predicate<? super E> |
getPredicate()
Gets the predicate.
|
Closure<? super E> |
getTrueClosure()
Gets the closure called when true.
|
static <E> Closure<E> |
ifClosure(Predicate<? super E> predicate,
Closure<? super E> trueClosure)
Factory method that performs validation.
|
static <E> Closure<E> |
ifClosure(Predicate<? super E> predicate,
Closure<? super E> trueClosure,
Closure<? super E> falseClosure)
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 nulltrueClosure
- closure used if true, not nullpublic IfClosure(Predicate<? super E> predicate, Closure<? super E> trueClosure, Closure<? super E> falseClosure)
ifClosure
if you want that.predicate
- predicate to switch on, not nulltrueClosure
- closure used if true, not nullfalseClosure
- closure used if false, not nullpublic 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 onpredicate
- predicate to switch ontrueClosure
- closure used if trueif
closurejava.lang.NullPointerException
- if either argument is nullpublic static <E> Closure<E> ifClosure(Predicate<? super E> predicate, Closure<? super E> trueClosure, Closure<? super E> falseClosure)
E
- the type that the closure acts onpredicate
- predicate to switch ontrueClosure
- closure used if truefalseClosure
- closure used if falseif
closurejava.lang.NullPointerException
- if any argument is nullpublic void execute(E input)
public Predicate<? super E> getPredicate()
public Closure<? super E> getTrueClosure()
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"