commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r666110 - in /commons/sandbox/functor/trunk/src: main/java/org/apache/commons/functor/core/composite/BinaryNot.java test/java/org/apache/commons/functor/core/composite/TestBinaryNot.java
Date Tue, 10 Jun 2008 13:52:00 GMT
Author: mbenson
Date: Tue Jun 10 06:51:59 2008
New Revision: 666110

URL: http://svn.apache.org/viewvc?rev=666110&view=rev
Log:
IllegalArgumentException on null constructor argument

Modified:
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryNot.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryNot.java

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryNot.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryNot.java?rev=666110&r1=666109&r2=666110&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryNot.java
(original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryNot.java
Tue Jun 10 06:51:59 2008
@@ -37,16 +37,19 @@
 public final class BinaryNot<L, R> implements BinaryPredicate<L, R>, Serializable
{
     // attributes
     // ------------------------------------------------------------------------
-    private BinaryPredicate<? super L, ? super R> predicate = null;
+    private BinaryPredicate<? super L, ? super R> predicate;
 
     // constructor
     // ------------------------------------------------------------------------
     /**
      * Create a new BinaryNot.
-     * @param p BinaryPredicate to negate
+     * @param predicate BinaryPredicate to negate
      */
-    public BinaryNot(BinaryPredicate<? super L, ? super R> p) {
-        this.predicate = p;
+    public BinaryNot(BinaryPredicate<? super L, ? super R> predicate) {
+        if (predicate == null) {
+            throw new IllegalArgumentException("BinaryPredicate argument was null");
+        }
+        this.predicate = predicate;
     }
 
     // predicate interface

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryNot.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryNot.java?rev=666110&r1=666109&r2=666110&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryNot.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryNot.java
Tue Jun 10 06:51:59 2008
@@ -44,7 +44,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new BinaryNot(new Constant(true));
+        return new BinaryNot<Object, Object>(Constant.TRUE);
     }
 
     // Lifecycle
@@ -62,20 +62,19 @@
     // ------------------------------------------------------------------------
 
     public void testTest() throws Exception {
-        BinaryPredicate truePred = new BinaryNot(new Constant(false));
+        BinaryPredicate<Object, Object> truePred = new BinaryNot<Object, Object>(Constant.FALSE);
         assertTrue(truePred.test(null,null));
         assertTrue(truePred.test("xyzzy","abcde"));
         assertTrue(truePred.test("xyzzy",new Integer(3)));
     }
 
     public void testEquals() throws Exception {
-        BinaryNot p = new BinaryNot(Constant.truePredicate());
+        BinaryNot<Object, Object> p = new BinaryNot<Object, Object>(Constant.TRUE);
         assertEquals(p,p);
-        assertObjectsAreEqual(p,new BinaryNot(new Constant(true)));
-        assertObjectsAreEqual(p,BinaryNot.not(new Constant(true)));
-        assertObjectsAreNotEqual(p,new BinaryNot(new Constant(false)));
-        assertObjectsAreNotEqual(p,Constant.truePredicate());
-        assertObjectsAreNotEqual(p,new BinaryNot(null));
+        assertObjectsAreEqual(p,new BinaryNot<Object, Object>(Constant.TRUE));
+        assertObjectsAreEqual(p,BinaryNot.not(Constant.TRUE));
+        assertObjectsAreNotEqual(p,new BinaryNot<Object, Object>(Constant.FALSE));
+        assertObjectsAreNotEqual(p,Constant.TRUE);
     }
 
     public void testNotNull() throws Exception {



Mime
View raw message