|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.collections15.functors.closure.IfClosure<E>
public class IfClosure<E>
Closure
decorator that conditionally executes a decorated
Closure
based on a predicate, like an if
statement.
Field Summary | |
---|---|
protected Predicate<? super E> |
predicate
The condition to determine whether or not the decorated Closure executes. |
protected Closure<? super E> |
trueClosure
The decorated Closure to execute if the condition evaluates
to true . |
Constructor Summary | |
---|---|
protected |
IfClosure(Predicate<? super E> predicate,
Closure<? super E> trueClosure)
Creates a Closure , that executes an existing
Closure only if a specified condition is met. |
Method Summary | ||
---|---|---|
static
|
decorate(Predicate<? super T> predicate,
Closure<? super T> trueClosure)
Decorates a Closure , returning a Closure that
executes only if a specified condition is met. |
|
void |
execute(E input)
Conditionally executes the Closure according to the result
of the Predicate . |
|
Predicate<? super E> |
getPredicate()
Gets the Predicate . |
|
Closure<? super E> |
getTrueClosure()
Gets the Closure executed when the Predicate
evaluate to true . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Predicate<? super E> predicate
Closure
executes.
protected final Closure<? super E> trueClosure
Closure
to execute if the condition evaluates
to true
.
Constructor Detail |
---|
protected IfClosure(Predicate<? super E> predicate, Closure<? super E> trueClosure)
Closure
, that executes an existing
Closure
only if a specified condition is met.
predicate
- The condition that must evaluate to true
if the Closure
is to execute.trueClosure
- The conditionally executed Closure
.
java.lang.IllegalArgumentException
- Thrown if any argument is null
.Method Detail |
---|
public static <T> Closure<T> decorate(Predicate<? super T> predicate, Closure<? super T> trueClosure)
Closure
, returning a Closure
that
executes only if a specified condition is met.
predicate
- The condition that must evaluate to true
if the Closure
is to execute.trueClosure
- The conditionally executed Closure
.
Closure
that executes only if the
Predicate
evaluates to true
.
java.lang.IllegalArgumentException
- Thrown if any argument is null
.public void execute(E input)
Closure
according to the result
of the Predicate
.
execute
in interface Closure<E>
input
- The input object to act upon.public Predicate<? super E> getPredicate()
Predicate
.
Predicate
.public Closure<? super E> getTrueClosure()
Closure
executed when the Predicate
evaluate to true
.
true Closure
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |