|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.collections4.functors.IfClosure<E>
public class IfClosure<E>
Closure implementation acts as an if statement calling one or other closure based on a predicate.
Constructor Summary | |
---|---|
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. |
Method Summary | ||
---|---|---|
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
|
ifClosure(Predicate<? super E> predicate,
Closure<? super E> trueClosure)
Factory method that performs validation. |
|
static
|
ifClosure(Predicate<? super E> predicate,
Closure<? super E> trueClosure,
Closure<? super E> falseClosure)
Factory method that performs validation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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 nullMethod Detail |
---|
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 onpredicate
- predicate to switch ontrueClosure
- closure used if true
if
closure
IllegalArgumentException
- 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 false
if
closure
IllegalArgumentException
- if any argument is nullpublic void execute(E input)
execute
in interface Closure<E>
input
- the input objectpublic Predicate<? super E> getPredicate()
public Closure<? super E> getTrueClosure()
public Closure<? super E> getFalseClosure()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |