|
|
@ -14,21 +14,31 @@ |
|
|
|
* See the License for the specific language governing permissions and |
|
|
|
* See the License for the specific language governing permissions and |
|
|
|
* limitations under the License. |
|
|
|
* limitations under the License. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
package org.apache.commons.collections4; |
|
|
|
package com.fr.third.org.apache.commons.collections4; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Collection; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.collections4.functors.ChainedClosure; |
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.ChainedClosure; |
|
|
|
import org.apache.commons.collections4.functors.EqualPredicate; |
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.EqualPredicate; |
|
|
|
import org.apache.commons.collections4.functors.ExceptionClosure; |
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.ExceptionClosure; |
|
|
|
import org.apache.commons.collections4.functors.ForClosure; |
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.ForClosure; |
|
|
|
import org.apache.commons.collections4.functors.IfClosure; |
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.IfClosure; |
|
|
|
import org.apache.commons.collections4.functors.InvokerTransformer; |
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.InvokerTransformer; |
|
|
|
import org.apache.commons.collections4.functors.NOPClosure; |
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.NOPClosure; |
|
|
|
import org.apache.commons.collections4.functors.SwitchClosure; |
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.SwitchClosure; |
|
|
|
import org.apache.commons.collections4.functors.TransformerClosure; |
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.TransformerClosure; |
|
|
|
import org.apache.commons.collections4.functors.WhileClosure; |
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.WhileClosure; |
|
|
|
|
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.ChainedClosure; |
|
|
|
|
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.EqualPredicate; |
|
|
|
|
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.ExceptionClosure; |
|
|
|
|
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.ForClosure; |
|
|
|
|
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.IfClosure; |
|
|
|
|
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.InvokerTransformer; |
|
|
|
|
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.NOPClosure; |
|
|
|
|
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.SwitchClosure; |
|
|
|
|
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.TransformerClosure; |
|
|
|
|
|
|
|
import com.fr.third.org.apache.commons.collections4.functors.WhileClosure; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* <code>ClosureUtils</code> provides reference implementations and utilities |
|
|
|
* <code>ClosureUtils</code> provides reference implementations and utilities |
|
|
@ -68,7 +78,7 @@ public class ClosureUtils { |
|
|
|
* Gets a Closure that always throws an exception. |
|
|
|
* Gets a Closure that always throws an exception. |
|
|
|
* This could be useful during testing as a placeholder. |
|
|
|
* This could be useful during testing as a placeholder. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see org.apache.commons.collections4.functors.ExceptionClosure |
|
|
|
* @see ExceptionClosure |
|
|
|
* |
|
|
|
* |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @return the closure |
|
|
|
* @return the closure |
|
|
@ -81,7 +91,7 @@ public class ClosureUtils { |
|
|
|
* Gets a Closure that will do nothing. |
|
|
|
* Gets a Closure that will do nothing. |
|
|
|
* This could be useful during testing as a placeholder. |
|
|
|
* This could be useful during testing as a placeholder. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see org.apache.commons.collections4.functors.NOPClosure |
|
|
|
* @see NOPClosure |
|
|
|
* |
|
|
|
* |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @return the closure |
|
|
|
* @return the closure |
|
|
@ -95,7 +105,7 @@ public class ClosureUtils { |
|
|
|
* The transformer will be called using the closure's input object. |
|
|
|
* The transformer will be called using the closure's input object. |
|
|
|
* The transformer's result will be ignored. |
|
|
|
* The transformer's result will be ignored. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see org.apache.commons.collections4.functors.TransformerClosure |
|
|
|
* @see TransformerClosure |
|
|
|
* |
|
|
|
* |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param transformer the transformer to run each time in the closure, null means nop |
|
|
|
* @param transformer the transformer to run each time in the closure, null means nop |
|
|
@ -110,7 +120,7 @@ public class ClosureUtils { |
|
|
|
* <p> |
|
|
|
* <p> |
|
|
|
* A null closure or zero count returns the <code>NOPClosure</code>. |
|
|
|
* A null closure or zero count returns the <code>NOPClosure</code>. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see org.apache.commons.collections4.functors.ForClosure |
|
|
|
* @see ForClosure |
|
|
|
* |
|
|
|
* |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param count the number of times to loop |
|
|
|
* @param count the number of times to loop |
|
|
@ -125,7 +135,7 @@ public class ClosureUtils { |
|
|
|
* Creates a Closure that will call the closure repeatedly until the |
|
|
|
* Creates a Closure that will call the closure repeatedly until the |
|
|
|
* predicate returns false. |
|
|
|
* predicate returns false. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see org.apache.commons.collections4.functors.WhileClosure |
|
|
|
* @see WhileClosure |
|
|
|
* |
|
|
|
* |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param predicate the predicate to use as an end of loop test, not null |
|
|
|
* @param predicate the predicate to use as an end of loop test, not null |
|
|
@ -141,7 +151,7 @@ public class ClosureUtils { |
|
|
|
* Creates a Closure that will call the closure once and then repeatedly |
|
|
|
* Creates a Closure that will call the closure once and then repeatedly |
|
|
|
* until the predicate returns false. |
|
|
|
* until the predicate returns false. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see org.apache.commons.collections4.functors.WhileClosure |
|
|
|
* @see WhileClosure |
|
|
|
* |
|
|
|
* |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param closure the closure to call repeatedly, not null |
|
|
|
* @param closure the closure to call repeatedly, not null |
|
|
@ -158,8 +168,8 @@ public class ClosureUtils { |
|
|
|
* Creates a Closure that will invoke a specific method on the closure's |
|
|
|
* Creates a Closure that will invoke a specific method on the closure's |
|
|
|
* input object by reflection. |
|
|
|
* input object by reflection. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see org.apache.commons.collections4.functors.InvokerTransformer |
|
|
|
* @see InvokerTransformer |
|
|
|
* @see org.apache.commons.collections4.functors.TransformerClosure |
|
|
|
* @see TransformerClosure |
|
|
|
* |
|
|
|
* |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param methodName the name of the method |
|
|
|
* @param methodName the name of the method |
|
|
@ -175,8 +185,8 @@ public class ClosureUtils { |
|
|
|
* Creates a Closure that will invoke a specific method on the closure's |
|
|
|
* Creates a Closure that will invoke a specific method on the closure's |
|
|
|
* input object by reflection. |
|
|
|
* input object by reflection. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see org.apache.commons.collections4.functors.InvokerTransformer |
|
|
|
* @see InvokerTransformer |
|
|
|
* @see org.apache.commons.collections4.functors.TransformerClosure |
|
|
|
* @see TransformerClosure |
|
|
|
* |
|
|
|
* |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param methodName the name of the method |
|
|
|
* @param methodName the name of the method |
|
|
@ -196,7 +206,7 @@ public class ClosureUtils { |
|
|
|
* Create a new Closure that calls each closure in turn, passing the |
|
|
|
* Create a new Closure that calls each closure in turn, passing the |
|
|
|
* result into the next closure. |
|
|
|
* result into the next closure. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see org.apache.commons.collections4.functors.ChainedClosure |
|
|
|
* @see ChainedClosure |
|
|
|
* |
|
|
|
* |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param closures an array of closures to chain |
|
|
|
* @param closures an array of closures to chain |
|
|
@ -213,7 +223,7 @@ public class ClosureUtils { |
|
|
|
* result into the next closure. The ordering is that of the iterator() |
|
|
|
* result into the next closure. The ordering is that of the iterator() |
|
|
|
* method on the collection. |
|
|
|
* method on the collection. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see org.apache.commons.collections4.functors.ChainedClosure |
|
|
|
* @see ChainedClosure |
|
|
|
* |
|
|
|
* |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param closures a collection of closures to chain |
|
|
|
* @param closures a collection of closures to chain |
|
|
@ -230,7 +240,7 @@ public class ClosureUtils { |
|
|
|
* Create a new Closure that calls another closure based on the |
|
|
|
* Create a new Closure that calls another closure based on the |
|
|
|
* result of the specified predicate. |
|
|
|
* result of the specified predicate. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see org.apache.commons.collections4.functors.IfClosure |
|
|
|
* @see IfClosure |
|
|
|
* |
|
|
|
* |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param predicate the validating predicate |
|
|
|
* @param predicate the validating predicate |
|
|
@ -248,7 +258,7 @@ public class ClosureUtils { |
|
|
|
* Create a new Closure that calls one of two closures depending |
|
|
|
* Create a new Closure that calls one of two closures depending |
|
|
|
* on the specified predicate. |
|
|
|
* on the specified predicate. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see org.apache.commons.collections4.functors.IfClosure |
|
|
|
* @see IfClosure |
|
|
|
* |
|
|
|
* |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param predicate the predicate to switch on |
|
|
|
* @param predicate the predicate to switch on |
|
|
@ -271,7 +281,7 @@ public class ClosureUtils { |
|
|
|
* location 0 returned true. Each predicate is evaluated |
|
|
|
* location 0 returned true. Each predicate is evaluated |
|
|
|
* until one returns true. |
|
|
|
* until one returns true. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see org.apache.commons.collections4.functors.SwitchClosure |
|
|
|
* @see SwitchClosure |
|
|
|
* |
|
|
|
* |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param predicates an array of predicates to check, not null |
|
|
|
* @param predicates an array of predicates to check, not null |
|
|
@ -295,7 +305,7 @@ public class ClosureUtils { |
|
|
|
* until one returns true. If no predicates evaluate to true, the default |
|
|
|
* until one returns true. If no predicates evaluate to true, the default |
|
|
|
* closure is called. |
|
|
|
* closure is called. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see org.apache.commons.collections4.functors.SwitchClosure |
|
|
|
* @see SwitchClosure |
|
|
|
* |
|
|
|
* |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param predicates an array of predicates to check, not null |
|
|
|
* @param predicates an array of predicates to check, not null |
|
|
@ -323,7 +333,7 @@ public class ClosureUtils { |
|
|
|
* null key. The ordering is that of the iterator() method on the entryset |
|
|
|
* null key. The ordering is that of the iterator() method on the entryset |
|
|
|
* collection of the map. |
|
|
|
* collection of the map. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see org.apache.commons.collections4.functors.SwitchClosure |
|
|
|
* @see SwitchClosure |
|
|
|
* |
|
|
|
* |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param predicatesAndClosures a map of predicates to closures |
|
|
|
* @param predicatesAndClosures a map of predicates to closures |
|
|
@ -346,7 +356,7 @@ public class ClosureUtils { |
|
|
|
* default closure is called. The default closure is set in the map |
|
|
|
* default closure is called. The default closure is set in the map |
|
|
|
* using a null key. |
|
|
|
* using a null key. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see org.apache.commons.collections4.functors.SwitchClosure |
|
|
|
* @see SwitchClosure |
|
|
|
* |
|
|
|
* |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param <E> the type that the closure acts on |
|
|
|
* @param objectsAndClosures a map of objects to closures |
|
|
|
* @param objectsAndClosures a map of objects to closures |