public class IfClosure<E> extends Object implements Closure<E>, 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
closureNullPointerException
- 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
closureNullPointerException
- if any argument is nullpublic void execute(E input)
public Predicate<? super E> getPredicate()
public Closure<? super E> getTrueClosure()
public Closure<? super E> getFalseClosure()
Copyright © 2001–2019 The Apache Software Foundation. All rights reserved.