java.lang.Object | |
↳ | org.apache.commons.collections.ClosureUtils |
ClosureUtils
provides reference implementations and utilities
for the Closure functor interface. The supplied closures are:
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This class is not normally instantiated.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a Closure that calls a Transformer each time it is called.
| |||||||||||
Create a new Closure that calls each closure in turn, passing the
result into the next closure.
| |||||||||||
Create a new Closure that calls each closure in turn, passing the
result into the next closure.
| |||||||||||
Create a new Closure that calls two Closures, passing the result of
the first into the second.
| |||||||||||
Creates a Closure that will call the closure once and then repeatedly
until the predicate returns false.
| |||||||||||
Gets a Closure that always throws an exception.
| |||||||||||
Creates a Closure that will call the closure
count times. | |||||||||||
Create a new Closure that calls one of two closures depending
on the specified predicate.
| |||||||||||
Create a new Closure that calls another closure based on the
result of the specified predicate.
| |||||||||||
Creates a Closure that will invoke a specific method on the closure's
input object by reflection.
| |||||||||||
Creates a Closure that will invoke a specific method on the closure's
input object by reflection.
| |||||||||||
Gets a Closure that will do nothing.
| |||||||||||
Create a new Closure that calls one of the closures depending
on the predicates.
| |||||||||||
Create a new Closure that calls one of the closures depending
on the predicates.
| |||||||||||
Create a new Closure that calls one of the closures depending
on the predicates.
| |||||||||||
Create a new Closure that uses the input object as a key to find the
closure to call.
| |||||||||||
Creates a Closure that will call the closure repeatedly until the
predicate returns false.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
This class is not normally instantiated.
Creates a Closure that calls a Transformer each time it is called. The transformer will be called using the closure's input object. The transformer's result will be ignored.
transformer | the transformer to run each time in the closure, null means nop |
---|
Create a new Closure that calls each closure in turn, passing the result into the next closure.
closures | an array of closures to chain |
---|
chained
closureIllegalArgumentException | if the closures array is null |
---|---|
IllegalArgumentException | if any closure in the array is null |
Create a new Closure that calls each closure in turn, passing the result into the next closure. The ordering is that of the iterator() method on the collection.
closures | a collection of closures to chain |
---|
chained
closureIllegalArgumentException | if the closures collection is null |
---|---|
IllegalArgumentException | if the closures collection is empty |
IllegalArgumentException | if any closure in the collection is null |
Create a new Closure that calls two Closures, passing the result of the first into the second.
closure1 | the first closure |
---|---|
closure2 | the second closure |
chained
closureIllegalArgumentException | if either closure is null |
---|
Creates a Closure that will call the closure once and then repeatedly until the predicate returns false.
closure | the closure to call repeatedly, not null |
---|---|
predicate | the predicate to use as an end of loop test, not null |
do-while
closureIllegalArgumentException | if either argument is null |
---|
Gets a Closure that always throws an exception. This could be useful during testing as a placeholder.
Creates a Closure that will call the closure count
times.
A null closure or zero count returns the NOPClosure
.
count | the number of times to loop |
---|---|
closure | the closure to call repeatedly |
for
closure
Create a new Closure that calls one of two closures depending on the specified predicate.
predicate | the predicate to switch on |
---|---|
trueClosure | the closure called if the predicate is true |
falseClosure | the closure called if the predicate is false |
switch
closureIllegalArgumentException | if the predicate is null |
---|---|
IllegalArgumentException | if either closure is null |
Create a new Closure that calls another closure based on the result of the specified predicate.
predicate | the validating predicate |
---|---|
trueClosure | the closure called if the predicate is true |
if
closureIllegalArgumentException | if the predicate is null |
---|---|
IllegalArgumentException | if the closure is null |
Creates a Closure that will invoke a specific method on the closure's input object by reflection.
methodName | the name of the method |
---|
invoker
closureIllegalArgumentException | if the method name is null |
---|
Creates a Closure that will invoke a specific method on the closure's input object by reflection.
methodName | the name of the method |
---|---|
paramTypes | the parameter types |
args | the arguments |
invoker
closureIllegalArgumentException | if the method name is null |
---|---|
IllegalArgumentException | if the paramTypes and args don't match |
Gets a Closure that will do nothing. This could be useful during testing as a placeholder.
Create a new Closure that calls one of the closures depending on the predicates.
The closure at array location 0 is called if the predicate at array location 0 returned true. Each predicate is evaluated until one returns true.
predicates | an array of predicates to check, not null |
---|---|
closures | an array of closures to call, not null |
switch
closureIllegalArgumentException | if the either array is null |
---|---|
IllegalArgumentException | if any element in the arrays is null |
IllegalArgumentException | if the arrays are different sizes |
Create a new Closure that calls one of the closures depending on the predicates.
The closure at array location 0 is called if the predicate at array location 0 returned true. Each predicate is evaluated until one returns true. If no predicates evaluate to true, the default closure is called.
predicates | an array of predicates to check, not null |
---|---|
closures | an array of closures to call, not null |
defaultClosure | the default to call if no predicate matches |
switch
closureIllegalArgumentException | if the either array is null |
---|---|
IllegalArgumentException | if any element in the arrays is null |
IllegalArgumentException | if the arrays are different sizes |
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.
predicatesAndClosures | a map of predicates to closures |
---|
switch
closureIllegalArgumentException | if the map is null |
---|---|
IllegalArgumentException | if the map is empty |
IllegalArgumentException | if any closure in the map is null |
ClassCastException | if the map elements are of the wrong type |
Create a new Closure that uses the input object as a key to find the closure to call.
The Map consists of object keys and Closure values. A closure is called if the input object equals the key. If there is no match, the default closure is called. The default closure is set in the map using a null key.
objectsAndClosures | a map of objects to closures |
---|
IllegalArgumentException | if the map is null |
---|---|
IllegalArgumentException | if the map is empty |
IllegalArgumentException | if any closure in the map is null |
Creates a Closure that will call the closure repeatedly until the predicate returns false.
predicate | the predicate to use as an end of loop test, not null |
---|---|
closure | the closure to call repeatedly, not null |
while
closureIllegalArgumentException | if either argument is null |
---|