commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r666112 - in /commons/sandbox/functor/trunk/src: main/java/org/apache/commons/functor/adapter/IgnoreRightPredicate.java test/java/org/apache/commons/functor/adapter/TestIgnoreRightPredicate.java
Date Tue, 10 Jun 2008 13:55:41 GMT
Author: mbenson
Date: Tue Jun 10 06:55:41 2008
New Revision: 666112

URL: http://svn.apache.org/viewvc?rev=666112&view=rev
Log:
null guard constructor argument with IllegalArgumentException; make into a fully generic BinaryPredicate

Modified:
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightPredicate.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestIgnoreRightPredicate.java

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightPredicate.java?rev=666112&r1=666111&r2=666112&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightPredicate.java
(original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightPredicate.java
Tue Jun 10 06:55:41 2008
@@ -38,22 +38,25 @@
  * @version $Revision$ $Date$
  * @author Rodney Waldhoff
  */
-public final class IgnoreRightPredicate<A> implements BinaryPredicate<A, Object>,
Serializable {
+public final class IgnoreRightPredicate<L, R> implements BinaryPredicate<L, R>,
Serializable {
     /** The {@link UnaryPredicate UnaryPredicate} I'm wrapping. */
-    private UnaryPredicate<? super A> predicate;
+    private UnaryPredicate<? super L> predicate;
 
     /**
      * Create a new IgnoreRightPredicate.
      * @param predicate left
      */
-    public IgnoreRightPredicate(UnaryPredicate<? super A> predicate) {
+    public IgnoreRightPredicate(UnaryPredicate<? super L> predicate) {
+        if (predicate == null) {
+            throw new IllegalArgumentException("UnaryPredicate argument was null");
+        }
         this.predicate = predicate;
     }
 
     /**
      * {@inheritDoc}
      */
-    public boolean test(A left, Object right) {
+    public boolean test(L left, R right) {
         return predicate.test(left);
     }
 
@@ -61,7 +64,7 @@
      * {@inheritDoc}
      */
     public boolean equals(Object that) {
-        return that == this || (that instanceof IgnoreRightPredicate && equals((IgnoreRightPredicate<?>)
that));
+        return that == this || (that instanceof IgnoreRightPredicate && equals((IgnoreRightPredicate<?,
?>) that));
     }
 
     /**
@@ -69,7 +72,7 @@
      * @param that IgnoreRightPredicate to test
      * @return boolean
      */
-    public boolean equals(IgnoreRightPredicate<?> that) {
+    public boolean equals(IgnoreRightPredicate<?, ?> that) {
         return null != that && (null == predicate ? null == that.predicate : predicate.equals(that.predicate));
     }
 
@@ -93,11 +96,13 @@
 
     /**
      * Adapt a UnaryPredicate as an IgnoreRightPredicate
+     * @param <L>
+     * @param <R>
      * @param predicate to adapt
-     * @return IgnoreRightPredicate
+     * @return IgnoreRightPredicate<L, R>
      */
-    public static <A> IgnoreRightPredicate<A> adapt(UnaryPredicate<? super
A> predicate) {
-        return null == predicate ? null : new IgnoreRightPredicate<A>(predicate);
+    public static <L, R> IgnoreRightPredicate<L, R> adapt(UnaryPredicate<?
super L> predicate) {
+        return null == predicate ? null : new IgnoreRightPredicate<L, R>(predicate);
     }
 
 }

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestIgnoreRightPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestIgnoreRightPredicate.java?rev=666112&r1=666111&r2=666112&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestIgnoreRightPredicate.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestIgnoreRightPredicate.java
Tue Jun 10 06:55:41 2008
@@ -75,7 +75,6 @@
         assertObjectsAreNotEqual(p,new Constant(true));
         assertObjectsAreNotEqual(p,new IgnoreRightPredicate(new Constant(false)));
         assertObjectsAreNotEqual(p,new Constant(false));
-        assertObjectsAreEqual(new IgnoreRightPredicate(null),new IgnoreRightPredicate(null));
     }
 
     public void testAdaptNull() throws Exception {



Mime
View raw message