| Modifier and Type | Field and Description |
|---|---|
| private final Closure | iClosures
The matching closures to call |
| private final Closure | iDefault
The default closure to call if no tests match |
| private final Predicate | iPredicates
The tests to consider |
| private static final long | serialVersionUID
Serial version UID |
| Access | Constructor and Description |
|---|---|
| private | SwitchClosure(final boolean
if clone, final Predicate<? super E>[] true the input arguments will be clonedarray of predicates, no nulls predicates, final Closure<? super E>[] matching array of closures, no nulls closures, final Closure<? super E> the closure to use if no match, null means nop defaultClosure)Hidden constructor for the use by the static factory methods. |
| public | SwitchClosure(final Predicate<? super E>[]
array of predicates, cloned, no nulls predicates, final Closure<? super E>[] matching array of closures, cloned, no nulls closures, final Closure<? super E> the closure to use if no match, null means nop defaultClosure)Constructor that performs no validation. |
| Modifier and Type | Method and Description |
|---|---|
| public void | execute(final E
the input object input)Implements org. |
| public Closure | |
| public Closure | |
| public Predicate | |
| public static < the type that the closure acts on E> Closure | Returns: thechained closurearray of predicates, cloned, no nulls predicates, final Closure<? super E>[] matching array of closures, cloned, no nulls closures, final Closure<? super E> the closure to use if no match, null means nop defaultClosure)Factory method that performs validation and copies the parameter arrays. |
| public static < the type that the closure acts on E> Closure | Returns: theswitch closurea map of predicates to closures predicatesAndClosures)Create a new Closure that calls one of the closures depending on the predicates. |
| iClosures | back to summary |
|---|---|
| private final Closure<? super E>[] iClosures The matching closures to call | |
| iDefault | back to summary |
|---|---|
| private final Closure<? super E> iDefault The default closure to call if no tests match | |
| iPredicates | back to summary |
|---|---|
| private final Predicate<? super E>[] iPredicates The tests to consider | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serial version UID | |
| SwitchClosure | back to summary |
|---|---|
| private SwitchClosure(final boolean clone, final Predicate<? super E>[] predicates, final Closure<? super E>[] closures, final Closure<? super E> defaultClosure) Hidden constructor for the use by the static factory methods.
| |
| SwitchClosure | back to summary |
|---|---|
| public SwitchClosure(final Predicate<? super E>[] predicates, final Closure<? super E>[] closures, final Closure<? super E> defaultClosure) Constructor that performs no validation.
Use | |
| execute | back to summary |
|---|---|
| public void execute(final E input) Implements org. Executes the closure whose matching predicate returns true
| |
| getClosures | back to summary |
|---|---|
| public Closure Gets the closures.
| |
| getDefaultClosure | back to summary |
|---|---|
| public Closure Gets the default closure.
| |
| getPredicates | back to summary |
|---|---|
| public Predicate Gets the predicates.
| |
| switchClosure | back to summary |
|---|---|
| public static <E> Closure Factory method that performs validation and copies the parameter arrays.
| |
| switchClosure | back to summary |
|---|---|
| public static <E> Closure Create a new Closure that calls one of the closures depending on the predicates. The Map consists of Predicate keys and Closure values. A closure is called if its matching predicate returns true. Each predicate is evaluated until one returns true. If no predicates evaluate to true, the default closure is called. The default closure is set in the map with a null key. The ordering is that of the iterator() method on the entryset collection of the map.
| |