Author: mbenson
Date: Tue Jun 10 07:02:53 2008
New Revision: 666114

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

Modified:
    
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundProcedure.java
    
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundProcedure.java
    
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundProcedure.java
    
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundProcedure.java

Modified: 
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundProcedure.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundProcedure.java?rev=666114&r1=666113&r2=666114&view=diff
==============================================================================
--- 
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundProcedure.java
 (original)
+++ 
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundProcedure.java
 Tue Jun 10 07:02:53 2008
@@ -50,6 +50,9 @@
      * @param arg the constant argument to use
      */
     public LeftBoundProcedure(BinaryProcedure<? super L, ? super R> procedure, 
L arg) {
+        if (procedure == null) {
+            throw new IllegalArgumentException("BinaryProcedure argument was 
null");
+        }
         this.procedure = procedure;
         this.param = arg;
     }

Modified: 
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundProcedure.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundProcedure.java?rev=666114&r1=666113&r2=666114&view=diff
==============================================================================
--- 
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundProcedure.java
 (original)
+++ 
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundProcedure.java
 Tue Jun 10 07:02:53 2008
@@ -50,6 +50,9 @@
      * @param arg the constant argument to use
      */
     public RightBoundProcedure(BinaryProcedure<? super L, ? super R> 
procedure, R arg) {
+        if (procedure == null) {
+            throw new IllegalArgumentException("BinaryProcedure argument was 
null");
+        }
         this.procedure = procedure;
         this.param = arg;
     }

Modified: 
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundProcedure.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundProcedure.java?rev=666114&r1=666113&r2=666114&view=diff
==============================================================================
--- 
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundProcedure.java
 (original)
+++ 
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundProcedure.java
 Tue Jun 10 07:02:53 2008
@@ -45,7 +45,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new LeftBoundProcedure(new NoOp(),"xyzzy");
+        return new LeftBoundProcedure<Object, Object>(NoOp.INSTANCE,"xyzzy");
     }
 
     // Lifecycle
@@ -63,21 +63,21 @@
     // ------------------------------------------------------------------------
 
     public void testRun() throws Exception {
-        UnaryProcedure p = new LeftBoundProcedure(new 
BinaryFunctionBinaryProcedure(RightIdentity.FUNCTION),"foo");
+        UnaryProcedure<Object> p = new LeftBoundProcedure<Object, Object>(
+                new BinaryFunctionBinaryProcedure<Object, 
Object>(RightIdentity.FUNCTION), "foo");
         p.run(Boolean.TRUE);
         p.run(Boolean.FALSE);
     }
 
     public void testEquals() throws Exception {
-        UnaryProcedure f = new LeftBoundProcedure(new NoOp(),"xyzzy");
-        assertEquals(f,f);
-        assertObjectsAreEqual(f,new LeftBoundProcedure(new NoOp(),"xyzzy"));
-        assertObjectsAreNotEqual(f,new NoOp());
-        assertObjectsAreNotEqual(f,new LeftBoundProcedure(new 
BinaryFunctionBinaryProcedure(RightIdentity.FUNCTION),"xyzzy"));
-        assertObjectsAreNotEqual(f,new LeftBoundProcedure(new NoOp(),"foo"));
-        assertObjectsAreNotEqual(f,new LeftBoundProcedure(null,"xyzzy"));
-        assertObjectsAreNotEqual(f,new LeftBoundProcedure(new NoOp(),null));
-        assertObjectsAreEqual(new LeftBoundProcedure(null,null),new 
LeftBoundProcedure(null,null));
+        UnaryProcedure<Object> f = new LeftBoundProcedure<Object, 
Object>(NoOp.INSTANCE, "xyzzy");
+        assertEquals(f, f);
+        assertObjectsAreEqual(f, new LeftBoundProcedure<Object, 
Object>(NoOp.INSTANCE, "xyzzy"));
+        assertObjectsAreNotEqual(f, new NoOp());
+        assertObjectsAreNotEqual(f, new LeftBoundProcedure<Object, Object>(
+                new BinaryFunctionBinaryProcedure<Object, 
Object>(RightIdentity.FUNCTION), "xyzzy"));
+        assertObjectsAreNotEqual(f, new LeftBoundProcedure<Object, 
Object>(NoOp.INSTANCE, "foo"));
+        assertObjectsAreNotEqual(f, new LeftBoundProcedure<Object, 
Object>(NoOp.INSTANCE, null));
     }
 
     public void testAdaptNull() throws Exception {

Modified: 
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundProcedure.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundProcedure.java?rev=666114&r1=666113&r2=666114&view=diff
==============================================================================
--- 
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundProcedure.java
 (original)
+++ 
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundProcedure.java
 Tue Jun 10 07:02:53 2008
@@ -45,7 +45,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new RightBoundProcedure(new NoOp(),"xyzzy");
+        return new RightBoundProcedure<Object, Object>(NoOp.INSTANCE,"xyzzy");
     }
 
     // Lifecycle
@@ -63,21 +63,20 @@
     // ------------------------------------------------------------------------
 
     public void testRun() throws Exception {
-        UnaryProcedure p = new RightBoundProcedure(new 
BinaryFunctionBinaryProcedure(LeftIdentity.FUNCTION),"foo");
+        UnaryProcedure<Object> p = new RightBoundProcedure<Object, Object>(
+                new BinaryFunctionBinaryProcedure<Object, 
Object>(LeftIdentity.FUNCTION), "foo");
         p.run(Boolean.TRUE);
         p.run(Boolean.FALSE);
     }
 
     public void testEquals() throws Exception {
-        UnaryProcedure f = new RightBoundProcedure(new NoOp(),"xyzzy");
+        UnaryProcedure<Object> f = new RightBoundProcedure<Object, 
Object>(NoOp.INSTANCE,"xyzzy");
         assertEquals(f,f);
-        assertObjectsAreEqual(f,new RightBoundProcedure(new NoOp(),"xyzzy"));
-        assertObjectsAreNotEqual(f,new NoOp());
-        assertObjectsAreNotEqual(f,new RightBoundProcedure(new 
BinaryFunctionBinaryProcedure(LeftIdentity.FUNCTION),"xyzzy"));
-        assertObjectsAreNotEqual(f,new RightBoundProcedure(new NoOp(),"foo"));
-        assertObjectsAreNotEqual(f,new RightBoundProcedure(null,"xyzzy"));
-        assertObjectsAreNotEqual(f,new RightBoundProcedure(new NoOp(),null));
-        assertObjectsAreEqual(new RightBoundProcedure(null,null),new 
RightBoundProcedure(null,null));
+        assertObjectsAreEqual(f,new RightBoundProcedure<Object, 
Object>(NoOp.INSTANCE,"xyzzy"));
+        assertObjectsAreNotEqual(f,NoOp.INSTANCE);
+        assertObjectsAreNotEqual(f,new RightBoundProcedure<Object, Object>(new 
BinaryFunctionBinaryProcedure<Object, Object>(LeftIdentity.FUNCTION),"xyzzy"));
+        assertObjectsAreNotEqual(f,new RightBoundProcedure<Object, 
Object>(NoOp.INSTANCE,"foo"));
+        assertObjectsAreNotEqual(f,new RightBoundProcedure<Object, 
Object>(NoOp.INSTANCE,null));
     }
 
     public void testAdaptNull() throws Exception {
@@ -85,7 +84,7 @@
     }
 
     public void testAdapt() throws Exception {
-        assertNotNull(RightBoundProcedure.bind(new NoOp(),"xyzzy"));
-        assertNotNull(RightBoundProcedure.bind(new NoOp(),null));
+        assertNotNull(RightBoundProcedure.bind(NoOp.INSTANCE,"xyzzy"));
+        assertNotNull(RightBoundProcedure.bind(NoOp.INSTANCE,null));
     }
 }


Reply via email to