commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r666241 - in /commons/sandbox/functor/trunk/src: main/java/org/apache/commons/functor/adapter/UnaryPredicateUnaryFunction.java test/java/org/apache/commons/functor/adapter/TestUnaryPredicateUnaryFunction.java
Date Tue, 10 Jun 2008 18:02:23 GMT
Author: mbenson
Date: Tue Jun 10 11:02:23 2008
New Revision: 666241

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

Modified:
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/UnaryPredicateUnaryFunction.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestUnaryPredicateUnaryFunction.java

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/UnaryPredicateUnaryFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/UnaryPredicateUnaryFunction.java?rev=666241&r1=666240&r2=666241&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/UnaryPredicateUnaryFunction.java
(original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/UnaryPredicateUnaryFunction.java
Tue Jun 10 11:02:23 2008
@@ -46,6 +46,9 @@
      * @param predicate to adapt
      */
     public UnaryPredicateUnaryFunction(UnaryPredicate<? super A> predicate) {
+        if (predicate == null) {
+            throw new IllegalArgumentException("UnaryPredicate argument was null");
+        }
         this.predicate = predicate;
     }
 

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestUnaryPredicateUnaryFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestUnaryPredicateUnaryFunction.java?rev=666241&r1=666240&r2=666241&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestUnaryPredicateUnaryFunction.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestUnaryPredicateUnaryFunction.java
Tue Jun 10 11:02:23 2008
@@ -44,7 +44,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new UnaryPredicateUnaryFunction(new Constant(true));
+        return new UnaryPredicateUnaryFunction<Object>(Constant.TRUE);
     }
 
     // Lifecycle
@@ -62,23 +62,21 @@
     // ------------------------------------------------------------------------
 
     public void testTestWhenTrue() throws Exception {
-        UnaryFunction f = new UnaryPredicateUnaryFunction(new Constant(true));
+        UnaryFunction<Object, Boolean> f = new UnaryPredicateUnaryFunction<Object>(Constant.TRUE);
         assertEquals(Boolean.TRUE,f.evaluate(null));
     }
 
     public void testTestWhenFalse() throws Exception {
-        UnaryFunction f = new UnaryPredicateUnaryFunction(new Constant(false));
+        UnaryFunction<Object, Boolean> f = new UnaryPredicateUnaryFunction<Object>(Constant.FALSE);
         assertEquals(Boolean.FALSE,f.evaluate(null));
     }
 
     public void testEquals() throws Exception {
-        UnaryFunction f = new UnaryPredicateUnaryFunction(new Constant(true));
+        UnaryFunction<Object, Boolean> f = new UnaryPredicateUnaryFunction<Object>(Constant.TRUE);
         assertEquals(f,f);
-        assertObjectsAreEqual(f,new UnaryPredicateUnaryFunction(new Constant(true)));
-        assertObjectsAreNotEqual(f,new Constant("x"));
-        assertObjectsAreNotEqual(f,new UnaryPredicateUnaryFunction(new Constant(false)));
-        assertObjectsAreNotEqual(f,new UnaryPredicateUnaryFunction(null));
-        assertObjectsAreEqual(new UnaryPredicateUnaryFunction(null),new UnaryPredicateUnaryFunction(null));
+        assertObjectsAreEqual(f,new UnaryPredicateUnaryFunction<Object>(Constant.TRUE));
+        assertObjectsAreNotEqual(f,Constant.of("x"));
+        assertObjectsAreNotEqual(f,new UnaryPredicateUnaryFunction<Object>(Constant.FALSE));
     }
 
     public void testAdaptNull() throws Exception {
@@ -86,6 +84,6 @@
     }
 
     public void testAdapt() throws Exception {
-        assertNotNull(UnaryPredicateUnaryFunction.adapt(new Constant(true)));
+        assertNotNull(UnaryPredicateUnaryFunction.adapt(Constant.TRUE));
     }
 }



Mime
View raw message