From 91d751cc0c32c9aef45f1b0ec1cf8dde9e2478b5 Mon Sep 17 00:00:00 2001 From: Stephen Colebourne Date: Wed, 26 May 2004 21:50:52 +0000 Subject: [PATCH] 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 --- .../org/apache/commons/collections/ClosureUtils.java | 10 ++++++---- .../org/apache/commons/collections/PredicateUtils.java | 8 +++++--- .../apache/commons/collections/TransformerUtils.java | 5 +++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/java/org/apache/commons/collections/ClosureUtils.java b/src/java/org/apache/commons/collections/ClosureUtils.java index 4259366ac..f40073643 100644 --- a/src/java/org/apache/commons/collections/ClosureUtils.java +++ b/src/java/org/apache/commons/collections/ClosureUtils.java @@ -20,9 +20,11 @@ import java.util.Iterator; import java.util.Map; 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.ForClosure; 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.SwitchClosure; import org.apache.commons.collections.functors.TransformerClosure; @@ -46,7 +48,7 @@ import org.apache.commons.collections.functors.WhileClosure; * All the supplied closures are Serializable. * * @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 */ @@ -155,7 +157,7 @@ public class ClosureUtils { */ public static Closure invokerClosure(String methodName) { // 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) { // 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; for (Iterator it = objectsAndClosures.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); - preds[i] = PredicateUtils.equalPredicate(entry.getKey()); + preds[i] = EqualPredicate.getInstance(entry.getKey()); trs[i] = (Closure) entry.getValue(); i++; } diff --git a/src/java/org/apache/commons/collections/PredicateUtils.java b/src/java/org/apache/commons/collections/PredicateUtils.java index 011005fec..65c96fec4 100644 --- a/src/java/org/apache/commons/collections/PredicateUtils.java +++ b/src/java/org/apache/commons/collections/PredicateUtils.java @@ -25,6 +25,7 @@ import org.apache.commons.collections.functors.ExceptionPredicate; import org.apache.commons.collections.functors.FalsePredicate; import org.apache.commons.collections.functors.IdentityPredicate; 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.NotNullPredicate; import org.apache.commons.collections.functors.NotPredicate; @@ -60,11 +61,12 @@ import org.apache.commons.collections.functors.UniquePredicate; *
  • False - always return false *
  • Exception - always throws an exception *
  • NullIsException/NullIsFalse/NullIsTrue - check for null input + *
  • Transformed - transforms the input before calling the predicate * * All the supplied predicates are Serializable. * * @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 Ola Berg @@ -213,7 +215,7 @@ public class PredicateUtils { */ public static Predicate invokerPredicate(String methodName){ // 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){ // 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 diff --git a/src/java/org/apache/commons/collections/TransformerUtils.java b/src/java/org/apache/commons/collections/TransformerUtils.java index 90f160d1b..68ba66c5c 100644 --- a/src/java/org/apache/commons/collections/TransformerUtils.java +++ b/src/java/org/apache/commons/collections/TransformerUtils.java @@ -23,6 +23,7 @@ import org.apache.commons.collections.functors.ChainedTransformer; import org.apache.commons.collections.functors.CloneTransformer; import org.apache.commons.collections.functors.ClosureTransformer; 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.FactoryTransformer; import org.apache.commons.collections.functors.InstantiateTransformer; @@ -56,7 +57,7 @@ import org.apache.commons.collections.functors.SwitchTransformer; * All the supplied transformers are Serializable. * * @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 James Carman @@ -339,7 +340,7 @@ public class TransformerUtils { int i = 0; for (Iterator it = objectsAndTransformers.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); - preds[i] = PredicateUtils.equalPredicate(entry.getKey()); + preds[i] = EqualPredicate.getInstance(entry.getKey()); trs[i] = (Transformer) entry.getValue(); i++; }