commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r666243 - in /commons/sandbox/functor/trunk/src: main/java/org/apache/commons/functor/adapter/ test/java/org/apache/commons/functor/adapter/ test/java/org/apache/commons/functor/core/
Date Tue, 10 Jun 2008 18:08:33 GMT
Author: mbenson
Date: Tue Jun 10 11:08:32 2008
New Revision: 666243

URL: http://svn.apache.org/viewvc?rev=666243&view=rev
Log:
unchecked warnings; IllegalArgumentExceptions on null constructor args

Modified:
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/UnaryProcedureUnaryFunction.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestUnaryProcedureUnaryFunction.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIdentity.java

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/UnaryProcedureUnaryFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/UnaryProcedureUnaryFunction.java?rev=666243&r1=666242&r2=666243&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/UnaryProcedureUnaryFunction.java
(original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/UnaryProcedureUnaryFunction.java
Tue Jun 10 11:08:32 2008
@@ -47,6 +47,9 @@
      * @param procedure to adapt
      */
     public UnaryProcedureUnaryFunction(UnaryProcedure<? super A> procedure) {
+        if (procedure == null) {
+            throw new IllegalArgumentException("UnaryProcedure argument was null");
+        }
         this.procedure = procedure;
     }
 

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestUnaryProcedureUnaryFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestUnaryProcedureUnaryFunction.java?rev=666243&r1=666242&r2=666243&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestUnaryProcedureUnaryFunction.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestUnaryProcedureUnaryFunction.java
Tue Jun 10 11:08:32 2008
@@ -46,7 +46,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new UnaryProcedureUnaryFunction(new NoOp());
+        return new UnaryProcedureUnaryFunction<Object, Object>(NoOp.INSTANCE);
     }
 
     // Lifecycle
@@ -64,19 +64,20 @@
     // ------------------------------------------------------------------------
 
     public void testEvaluate() throws Exception {
-        UnaryFunction f = new UnaryProcedureUnaryFunction(new NoOp());
+        UnaryFunction<Object, Object> f = new UnaryProcedureUnaryFunction<Object,
Object>(NoOp.INSTANCE);
         assertNull(f.evaluate(null));
     }
 
     public void testEquals() throws Exception {
-        UnaryFunction f = new UnaryProcedureUnaryFunction(new NoOp());
+        UnaryFunction<Object, Object> f = new UnaryProcedureUnaryFunction<Object,
Object>(NoOp.INSTANCE);
         assertEquals(f,f);
-        assertObjectsAreEqual(f,new UnaryProcedureUnaryFunction(new NoOp()));
-        assertObjectsAreNotEqual(f,new Constant("x"));
-        assertObjectsAreNotEqual(f,new UnaryProcedureUnaryFunction(new UnaryProcedure() {
public void run(Object a) { } }));
-        assertObjectsAreNotEqual(f,new Constant(null));
-        assertObjectsAreNotEqual(f,new UnaryProcedureUnaryFunction(null));
-        assertObjectsAreEqual(new UnaryProcedureUnaryFunction(null),new UnaryProcedureUnaryFunction(null));
+        assertObjectsAreEqual(f,new UnaryProcedureUnaryFunction<Object, Object>(NoOp.INSTANCE));
+        assertObjectsAreNotEqual(f,Constant.of("x"));
+        assertObjectsAreNotEqual(f, new UnaryProcedureUnaryFunction<Object, Object>(new
UnaryProcedure<Object>() {
+            public void run(Object a) {
+            }
+        }));
+        assertObjectsAreNotEqual(f,Constant.of(null));
     }
 
     public void testAdaptNull() throws Exception {

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIdentity.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIdentity.java?rev=666243&r1=666242&r2=666243&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIdentity.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIdentity.java
Tue Jun 10 11:08:32 2008
@@ -44,7 +44,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new Identity();
+        return Identity.INSTANCE;
     }
 
     // Lifecycle
@@ -62,7 +62,7 @@
     // ------------------------------------------------------------------------
 
     public void testEvaluate() throws Exception {
-        UnaryFunction f = new Identity();
+        UnaryFunction<Object, Object> f = new Identity<Object>();
         assertNull(f.evaluate(null));
         assertEquals("xyzzy",f.evaluate("xyzzy"));
         assertEquals(new Integer(3),f.evaluate(new Integer(3)));
@@ -71,7 +71,7 @@
     }
 
     public void testTest() throws Exception {
-        UnaryPredicate p = new Identity();
+        UnaryPredicate<Object> p = new Identity<Object>();
         assertTrue(p.test(Boolean.TRUE));
         assertTrue(!p.test(Boolean.FALSE));
         try {
@@ -88,11 +88,11 @@
         }
     }
     public void testEquals() throws Exception {
-        UnaryFunction f = new Identity();
+        UnaryFunction<Object, Object> f = new Identity<Object>();
         assertEquals(f,f);
-        assertObjectsAreEqual(f,new Identity());
+        assertObjectsAreEqual(f,new Identity<Object>());
         assertObjectsAreEqual(f,Identity.instance());
-        assertObjectsAreNotEqual(f,new Constant("abcde"));
+        assertObjectsAreNotEqual(f,Constant.of("abcde"));
     }
 
     public void testConstant() throws Exception {



Mime
View raw message