Replace calls to Utils classes with direct references to implementations

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131750 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2004-05-26 21:50:52 +00:00
parent 49c909bea0
commit 91d751cc0c
3 changed files with 14 additions and 9 deletions

View File

@ -20,9 +20,11 @@ import java.util.Iterator;
import java.util.Map; import java.util.Map;
import org.apache.commons.collections.functors.ChainedClosure; import org.apache.commons.collections.functors.ChainedClosure;
import org.apache.commons.collections.functors.EqualPredicate;
import org.apache.commons.collections.functors.ExceptionClosure; import org.apache.commons.collections.functors.ExceptionClosure;
import org.apache.commons.collections.functors.ForClosure; import org.apache.commons.collections.functors.ForClosure;
import org.apache.commons.collections.functors.IfClosure; import org.apache.commons.collections.functors.IfClosure;
import org.apache.commons.collections.functors.InvokerTransformer;
import org.apache.commons.collections.functors.NOPClosure; import org.apache.commons.collections.functors.NOPClosure;
import org.apache.commons.collections.functors.SwitchClosure; import org.apache.commons.collections.functors.SwitchClosure;
import org.apache.commons.collections.functors.TransformerClosure; import org.apache.commons.collections.functors.TransformerClosure;
@ -46,7 +48,7 @@ import org.apache.commons.collections.functors.WhileClosure;
* All the supplied closures are Serializable. * All the supplied closures are Serializable.
* *
* @since Commons Collections 3.0 * @since Commons Collections 3.0
* @version $Revision: 1.8 $ $Date: 2004/04/14 21:47:47 $ * @version $Revision: 1.9 $ $Date: 2004/05/26 21:50:52 $
* *
* @author Stephen Colebourne * @author Stephen Colebourne
*/ */
@ -155,7 +157,7 @@ public class ClosureUtils {
*/ */
public static Closure invokerClosure(String methodName) { public static Closure invokerClosure(String methodName) {
// reuse transformer as it has caching - this is lazy really, should have inner class here // reuse transformer as it has caching - this is lazy really, should have inner class here
return asClosure(TransformerUtils.invokerTransformer(methodName, null, null)); return asClosure(InvokerTransformer.getInstance(methodName));
} }
/** /**
@ -174,7 +176,7 @@ public class ClosureUtils {
*/ */
public static Closure invokerClosure(String methodName, Class[] paramTypes, Object[] args) { public static Closure invokerClosure(String methodName, Class[] paramTypes, Object[] args) {
// reuse transformer as it has caching - this is lazy really, should have inner class here // reuse transformer as it has caching - this is lazy really, should have inner class here
return asClosure(TransformerUtils.invokerTransformer(methodName, paramTypes, args)); return asClosure(InvokerTransformer.getInstance(methodName, paramTypes, args));
} }
/** /**
@ -339,7 +341,7 @@ public class ClosureUtils {
int i = 0; int i = 0;
for (Iterator it = objectsAndClosures.entrySet().iterator(); it.hasNext();) { for (Iterator it = objectsAndClosures.entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next(); Map.Entry entry = (Map.Entry) it.next();
preds[i] = PredicateUtils.equalPredicate(entry.getKey()); preds[i] = EqualPredicate.getInstance(entry.getKey());
trs[i] = (Closure) entry.getValue(); trs[i] = (Closure) entry.getValue();
i++; i++;
} }

View File

@ -25,6 +25,7 @@ import org.apache.commons.collections.functors.ExceptionPredicate;
import org.apache.commons.collections.functors.FalsePredicate; import org.apache.commons.collections.functors.FalsePredicate;
import org.apache.commons.collections.functors.IdentityPredicate; import org.apache.commons.collections.functors.IdentityPredicate;
import org.apache.commons.collections.functors.InstanceofPredicate; import org.apache.commons.collections.functors.InstanceofPredicate;
import org.apache.commons.collections.functors.InvokerTransformer;
import org.apache.commons.collections.functors.NonePredicate; import org.apache.commons.collections.functors.NonePredicate;
import org.apache.commons.collections.functors.NotNullPredicate; import org.apache.commons.collections.functors.NotNullPredicate;
import org.apache.commons.collections.functors.NotPredicate; import org.apache.commons.collections.functors.NotPredicate;
@ -60,11 +61,12 @@ import org.apache.commons.collections.functors.UniquePredicate;
* <li>False - always return false * <li>False - always return false
* <li>Exception - always throws an exception * <li>Exception - always throws an exception
* <li>NullIsException/NullIsFalse/NullIsTrue - check for null input * <li>NullIsException/NullIsFalse/NullIsTrue - check for null input
* <li>Transformed - transforms the input before calling the predicate
* </ul> * </ul>
* All the supplied predicates are Serializable. * All the supplied predicates are Serializable.
* *
* @since Commons Collections 3.0 * @since Commons Collections 3.0
* @version $Revision: 1.18 $ $Date: 2004/04/14 21:47:47 $ * @version $Revision: 1.19 $ $Date: 2004/05/26 21:50:52 $
* *
* @author Stephen Colebourne * @author Stephen Colebourne
* @author Ola Berg * @author Ola Berg
@ -213,7 +215,7 @@ public class PredicateUtils {
*/ */
public static Predicate invokerPredicate(String methodName){ public static Predicate invokerPredicate(String methodName){
// reuse transformer as it has caching - this is lazy really, should have inner class here // reuse transformer as it has caching - this is lazy really, should have inner class here
return asPredicate(TransformerUtils.invokerTransformer(methodName)); return asPredicate(InvokerTransformer.getInstance(methodName));
} }
/** /**
@ -238,7 +240,7 @@ public class PredicateUtils {
*/ */
public static Predicate invokerPredicate(String methodName, Class[] paramTypes, Object[] args){ public static Predicate invokerPredicate(String methodName, Class[] paramTypes, Object[] args){
// reuse transformer as it has caching - this is lazy really, should have inner class here // reuse transformer as it has caching - this is lazy really, should have inner class here
return asPredicate(TransformerUtils.invokerTransformer(methodName, paramTypes, args)); return asPredicate(InvokerTransformer.getInstance(methodName, paramTypes, args));
} }
// Boolean combinations // Boolean combinations

View File

@ -23,6 +23,7 @@ import org.apache.commons.collections.functors.ChainedTransformer;
import org.apache.commons.collections.functors.CloneTransformer; import org.apache.commons.collections.functors.CloneTransformer;
import org.apache.commons.collections.functors.ClosureTransformer; import org.apache.commons.collections.functors.ClosureTransformer;
import org.apache.commons.collections.functors.ConstantTransformer; import org.apache.commons.collections.functors.ConstantTransformer;
import org.apache.commons.collections.functors.EqualPredicate;
import org.apache.commons.collections.functors.ExceptionTransformer; import org.apache.commons.collections.functors.ExceptionTransformer;
import org.apache.commons.collections.functors.FactoryTransformer; import org.apache.commons.collections.functors.FactoryTransformer;
import org.apache.commons.collections.functors.InstantiateTransformer; import org.apache.commons.collections.functors.InstantiateTransformer;
@ -56,7 +57,7 @@ import org.apache.commons.collections.functors.SwitchTransformer;
* All the supplied transformers are Serializable. * All the supplied transformers are Serializable.
* *
* @since Commons Collections 3.0 * @since Commons Collections 3.0
* @version $Revision: 1.12 $ $Date: 2004/04/14 21:47:47 $ * @version $Revision: 1.13 $ $Date: 2004/05/26 21:50:52 $
* *
* @author Stephen Colebourne * @author Stephen Colebourne
* @author James Carman * @author James Carman
@ -339,7 +340,7 @@ public class TransformerUtils {
int i = 0; int i = 0;
for (Iterator it = objectsAndTransformers.entrySet().iterator(); it.hasNext();) { for (Iterator it = objectsAndTransformers.entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next(); Map.Entry entry = (Map.Entry) it.next();
preds[i] = PredicateUtils.equalPredicate(entry.getKey()); preds[i] = EqualPredicate.getInstance(entry.getKey());
trs[i] = (Transformer) entry.getValue(); trs[i] = (Transformer) entry.getValue();
i++; i++;
} }