commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r815046 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/EqualPredicate.java
Date Tue, 15 Sep 2009 05:55:02 GMT
Author: bayard
Date: Tue Sep 15 05:55:02 2009
New Revision: 815046

URL: http://svn.apache.org/viewvc?rev=815046&view=rev
Log:
Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified;
mostly in r738956.

Also see the following revisions:

    ------------------------------------------------------------------------
    r643795 | skestle | 2008-04-02 01:49:57 -0700 (Wed, 02 Apr 2008) | 5 lines
    
    Generified EqualPredicate and created individual test class moved from TestPredicateUtils
    
    Added assertFalse() and assertTrue to BasicPredicateTestBase with (Predicate, Object)
parameters
    
    Issues: COLLECTIONS-243, COLLECTIONS-253, COLLECTIONS-293
    ------------------------------------------------------------------------

Modified:
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/EqualPredicate.java

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/EqualPredicate.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/EqualPredicate.java?rev=815046&r1=815045&r2=815046&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/EqualPredicate.java
(original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/functors/EqualPredicate.java
Tue Sep 15 05:55:02 2009
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.collections.functors;
 
+import static org.apache.commons.collections.functors.NullPredicate.nullPredicate;
+
 import java.io.Serializable;
 
 import org.apache.commons.collections.Predicate;
@@ -29,7 +31,7 @@
  *
  * @author Stephen Colebourne
  */
-public final class EqualPredicate implements Predicate, Serializable {
+public final class EqualPredicate<T> implements Predicate<T>, Serializable {
 
     /** Serial version UID */
     private static final long serialVersionUID = 5633766978029907089L;
@@ -43,12 +45,28 @@
      * @param object  the object to compare to
      * @return the predicate
      * @throws IllegalArgumentException if the predicate is null
+     * @deprecated use {@link #equalPredicate(Object)} instead.
+     */
+    @Deprecated
+    public static <T> Predicate<T> getInstance(T object) {
+        if (object == null) {
+            return nullPredicate();
+        }
+        return new EqualPredicate<T>(object);
+    }
+
+    /**
+     * Factory to create the identity predicate.
+     * 
+     * @param object  the object to compare to
+     * @return the predicate
+     * @throws IllegalArgumentException if the predicate is null
      */
-    public static Predicate getInstance(Object object) {
+    public static <T> Predicate<T> equalPredicate(T object) {
         if (object == null) {
-            return NullPredicate.INSTANCE;
+            return nullPredicate();
         }
-        return new EqualPredicate(object);
+        return new EqualPredicate<T>(object);
     }
 
     /**



Mime
View raw message