commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1476578 - in /commons/proper/collections/trunk/src: main/java/org/apache/commons/collections4/functors/DefaultEquator.java test/java/org/apache/commons/collections4/CollectionUtilsTest.java
Date Sat, 27 Apr 2013 14:02:30 GMT
Author: tn
Date: Sat Apr 27 14:02:30 2013
New Revision: 1476578

URL: http://svn.apache.org/r1476578
Log:
Make DefaultEquator a singleton, hide default ctor.

Modified:
    commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/functors/DefaultEquator.java
    commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java

Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/functors/DefaultEquator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/functors/DefaultEquator.java?rev=1476578&r1=1476577&r2=1476578&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/functors/DefaultEquator.java
(original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/functors/DefaultEquator.java
Sat Apr 27 14:02:30 2013
@@ -39,6 +39,24 @@ public class DefaultEquator<T> implement
     public static final int HASHCODE_NULL = -1;
 
     /**
+     * Factory returning the typed singleton instance.
+     * 
+     * @param <T>  the object type
+     * @return the singleton instance
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> DefaultEquator<T> defaultEquator() {
+        return (DefaultEquator<T>) DefaultEquator.INSTANCE;
+    }
+
+    /**
+     * Restricted constructor.
+     */
+    private DefaultEquator() {
+        super();
+    }
+
+    /**
      * {@inheritDoc} Delegates to {@link Object#equals(Object)}.
      */
     public boolean equate(final T o1, final T o2) {
@@ -59,14 +77,4 @@ public class DefaultEquator<T> implement
         return INSTANCE;
     }
 
-    /**
-     * Get a typed {@link DefaultEquator} instance.
-     * 
-     * @param <T>  the object type
-     * @return {@link DefaultEquator#INSTANCE}
-     */
-    @SuppressWarnings("unchecked")
-    public static <T> DefaultEquator<T> defaultEquator() {
-        return (DefaultEquator<T>) DefaultEquator.INSTANCE;
-    }
 }

Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java?rev=1476578&r1=1476577&r2=1476578&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java
(original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/CollectionUtilsTest.java
Sat Apr 27 14:02:30 2013
@@ -571,7 +571,7 @@ public class CollectionUtilsTest extends
         assertTrue(CollectionUtils.isEqualCollection(collectionA, collB, e));
         assertTrue(CollectionUtils.isEqualCollection(collB, collectionA, e));
         
-        final Equator<Number> defaultEquator = new DefaultEquator<Number>();
+        final Equator<Number> defaultEquator = DefaultEquator.defaultEquator();
         assertFalse(CollectionUtils.isEqualCollection(collectionA, collectionB, defaultEquator));
         assertFalse(CollectionUtils.isEqualCollection(collectionA, collB, defaultEquator));
       
     }



Mime
View raw message