commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r666176 - in /commons/sandbox/functor/trunk/src: main/java/org/apache/commons/functor/core/composite/TransposedProcedure.java test/java/org/apache/commons/functor/core/composite/TestTransposedProcedure.java
Date Tue, 10 Jun 2008 16:06:54 GMT
Author: mbenson
Date: Tue Jun 10 09:06:54 2008
New Revision: 666176

URL: http://svn.apache.org/viewvc?rev=666176&view=rev
Log:
unchecked warnings + throw IllegalArgumentException on null constructor arg

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

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/TransposedProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/TransposedProcedure.java?rev=666176&r1=666175&r2=666176&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/TransposedProcedure.java
(original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/TransposedProcedure.java
Tue Jun 10 09:06:54 2008
@@ -48,10 +48,13 @@
     // ------------------------------------------------------------------------
     /**
      * Create a new TransposedProcedure.
-     * @param p BinaryProcedure to transpose
+     * @param procedure BinaryProcedure to transpose
      */
-    public TransposedProcedure(BinaryProcedure<? super R, ? super L> p) {
-        procedure = p;
+    public TransposedProcedure(BinaryProcedure<? super R, ? super L> procedure) {
+        if (procedure == null) {
+            throw new IllegalArgumentException("BinaryProcedure argument was null");
+        }
+        this.procedure = procedure;
     }
 
     // functor interface

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedProcedure.java?rev=666176&r1=666175&r2=666176&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedProcedure.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedProcedure.java
Tue Jun 10 09:06:54 2008
@@ -44,7 +44,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new TransposedProcedure(NoOp.instance());
+        return new TransposedProcedure<Object, Object>(NoOp.INSTANCE);
     }
 
     // Lifecycle
@@ -63,7 +63,7 @@
 
     public void testEvaluate() throws Exception {
         LeftNotNullCounter counter = new LeftNotNullCounter();
-        BinaryProcedure p = new TransposedProcedure(counter);
+        BinaryProcedure<Object, Object> p = new TransposedProcedure<Object, Object>(counter);
         assertEquals(0,counter.count);
         p.run(null,"not null");
         assertEquals(1,counter.count);
@@ -72,13 +72,12 @@
     }
 
     public void testEquals() throws Exception {
-        BinaryProcedure p = new TransposedProcedure(NoOp.instance());
+        BinaryProcedure<Object, Object> p = new TransposedProcedure<Object, Object>(NoOp.INSTANCE);
         assertEquals(p,p);
-        assertObjectsAreEqual(p,new TransposedProcedure(NoOp.instance()));
-        assertObjectsAreEqual(p,TransposedProcedure.transpose(NoOp.instance()));
-        assertObjectsAreNotEqual(p,new TransposedProcedure(new TransposedProcedure(NoOp.instance())));
-        assertObjectsAreNotEqual(p,new TransposedProcedure(null));
-        assertObjectsAreNotEqual(p,new NoOp());
+        assertObjectsAreEqual(p,new TransposedProcedure<Object, Object>(NoOp.INSTANCE));
+        assertObjectsAreEqual(p,TransposedProcedure.transpose(NoOp.INSTANCE));
+        assertObjectsAreNotEqual(p,new TransposedProcedure<Object, Object>(new TransposedProcedure<Object,
Object>(NoOp.INSTANCE)));
+        assertObjectsAreNotEqual(p,NoOp.INSTANCE);
     }
 
     public void testTransposeNull() throws Exception {
@@ -86,13 +85,13 @@
     }
 
     public void testTranspose() throws Exception {
-        assertNotNull(TransposedProcedure.transpose(new NoOp()));
+        assertNotNull(TransposedProcedure.transpose(NoOp.INSTANCE));
     }
 
     // Classes
     // ------------------------------------------------------------------------
 
-    static class LeftNotNullCounter implements BinaryProcedure {
+    static class LeftNotNullCounter implements BinaryProcedure<Object, Object> {
         public void run(Object a, Object b) {
             if (null != a) {
                 count++;



Mime
View raw message