You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mb...@apache.org on 2008/06/10 16:21:02 UTC
svn commit: r666119 - in /commons/sandbox/functor/trunk/src:
main/java/org/apache/commons/functor/adapter/
test/java/org/apache/commons/functor/adapter/
Author: mbenson
Date: Tue Jun 10 07:21:02 2008
New Revision: 666119
URL: http://svn.apache.org/viewvc?rev=666119&view=rev
Log:
clean up unchecked warnings in testcases; throw IllegalArgumentException on null constructor args
Modified:
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundPredicate.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundPredicate.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundPredicate.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundPredicate.java
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundPredicate.java?rev=666119&r1=666118&r2=666119&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundPredicate.java Tue Jun 10 07:21:02 2008
@@ -51,6 +51,9 @@
* @param arg the constant argument to use
*/
public LeftBoundPredicate(BinaryPredicate<? super L, ? super R> predicate, L arg) {
+ if (predicate == null) {
+ throw new IllegalArgumentException("BinaryPredicate argument was null");
+ }
this.predicate = predicate;
this.param = arg;
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundPredicate.java?rev=666119&r1=666118&r2=666119&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundPredicate.java Tue Jun 10 07:21:02 2008
@@ -50,6 +50,9 @@
* @param arg the constant argument to use
*/
public RightBoundPredicate(BinaryPredicate<? super L, ? super R> predicate, R arg) {
+ if (predicate == null) {
+ throw new IllegalArgumentException("BinaryPredicate argument was null");
+ }
this.predicate = predicate;
this.param = arg;
}
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundPredicate.java?rev=666119&r1=666118&r2=666119&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundPredicate.java Tue Jun 10 07:21:02 2008
@@ -45,7 +45,7 @@
// ------------------------------------------------------------------------
protected Object makeFunctor() {
- return new LeftBoundPredicate(new Constant(true),"xyzzy");
+ return new LeftBoundPredicate<Object, Object>(Constant.TRUE,"xyzzy");
}
// Lifecycle
@@ -63,21 +63,20 @@
// ------------------------------------------------------------------------
public void testTest() throws Exception {
- UnaryPredicate p = new LeftBoundPredicate(new BinaryFunctionBinaryPredicate(RightIdentity.FUNCTION),"foo");
+ UnaryPredicate<Boolean> p = new LeftBoundPredicate<Object, Boolean>(
+ new BinaryFunctionBinaryPredicate<Object, Boolean>(RightIdentity.<Object, Boolean> function()), "foo");
assertEquals(true,p.test(Boolean.TRUE));
assertEquals(false,p.test(Boolean.FALSE));
}
public void testEquals() throws Exception {
- UnaryPredicate p = new LeftBoundPredicate(new Constant(true),"xyzzy");
+ UnaryPredicate<Boolean> p = new LeftBoundPredicate<Object, Boolean>(Constant.TRUE,"xyzzy");
assertEquals(p,p);
- assertObjectsAreEqual(p,new LeftBoundPredicate(new Constant(true),"xyzzy"));
- assertObjectsAreNotEqual(p,new Constant(true));
- assertObjectsAreNotEqual(p,new LeftBoundPredicate(new Constant(false),"xyzzy"));
- assertObjectsAreNotEqual(p,new LeftBoundPredicate(new Constant(true),"foo"));
- assertObjectsAreNotEqual(p,new LeftBoundPredicate(null,"xyzzy"));
- assertObjectsAreNotEqual(p,new LeftBoundPredicate(new Constant(true),null));
- assertObjectsAreEqual(new LeftBoundPredicate(null,null),new LeftBoundPredicate(null,null));
+ assertObjectsAreEqual(p,new LeftBoundPredicate<Object, Boolean>(Constant.TRUE,"xyzzy"));
+ assertObjectsAreNotEqual(p,Constant.TRUE);
+ assertObjectsAreNotEqual(p,new LeftBoundPredicate<Object, Boolean>(Constant.FALSE,"xyzzy"));
+ assertObjectsAreNotEqual(p,new LeftBoundPredicate<Object, Boolean>(Constant.TRUE,"foo"));
+ assertObjectsAreNotEqual(p,new LeftBoundPredicate<Object, Boolean>(Constant.TRUE,null));
}
public void testAdaptNull() throws Exception {
@@ -85,7 +84,7 @@
}
public void testAdapt() throws Exception {
- assertNotNull(LeftBoundPredicate.bind(new Constant(false),"xyzzy"));
- assertNotNull(LeftBoundPredicate.bind(new Constant(false),null));
+ assertNotNull(LeftBoundPredicate.bind(Constant.FALSE,"xyzzy"));
+ assertNotNull(LeftBoundPredicate.bind(Constant.FALSE,null));
}
}
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundPredicate.java?rev=666119&r1=666118&r2=666119&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundPredicate.java Tue Jun 10 07:21:02 2008
@@ -45,7 +45,7 @@
// ------------------------------------------------------------------------
protected Object makeFunctor() {
- return new RightBoundPredicate(new Constant(true),"xyzzy");
+ return new RightBoundPredicate<Object, Object>(Constant.TRUE,"xyzzy");
}
// Lifecycle
@@ -63,21 +63,20 @@
// ------------------------------------------------------------------------
public void testTest() throws Exception {
- UnaryPredicate f = new RightBoundPredicate(new BinaryFunctionBinaryPredicate(LeftIdentity.FUNCTION),"foo");
+ UnaryPredicate<Boolean> f = new RightBoundPredicate<Boolean, Object>(
+ new BinaryFunctionBinaryPredicate<Boolean, Object>(LeftIdentity.<Boolean, Object> function()), "foo");
assertEquals(true,f.test(Boolean.TRUE));
assertEquals(false,f.test(Boolean.FALSE));
}
public void testEquals() throws Exception {
- UnaryPredicate f = new RightBoundPredicate(new Constant(true),"xyzzy");
+ UnaryPredicate<Boolean> f = new RightBoundPredicate<Boolean, Object>(Constant.TRUE,"xyzzy");
assertEquals(f,f);
- assertObjectsAreEqual(f,new RightBoundPredicate(new Constant(true),"xyzzy"));
- assertObjectsAreNotEqual(f,new Constant(true));
- assertObjectsAreNotEqual(f,new RightBoundPredicate(new Constant(false),"xyzzy"));
- assertObjectsAreNotEqual(f,new RightBoundPredicate(new Constant(true),"foo"));
- assertObjectsAreNotEqual(f,new RightBoundPredicate(null,"xyzzy"));
- assertObjectsAreNotEqual(f,new RightBoundPredicate(new Constant(true),null));
- assertObjectsAreEqual(new RightBoundPredicate(null,null),new RightBoundPredicate(null,null));
+ assertObjectsAreEqual(f,new RightBoundPredicate<Boolean, Object>(Constant.TRUE,"xyzzy"));
+ assertObjectsAreNotEqual(f,Constant.TRUE);
+ assertObjectsAreNotEqual(f,new RightBoundPredicate<Boolean, Object>(Constant.FALSE,"xyzzy"));
+ assertObjectsAreNotEqual(f,new RightBoundPredicate<Boolean, Object>(Constant.TRUE,"foo"));
+ assertObjectsAreNotEqual(f,new RightBoundPredicate<Boolean, Object>(Constant.TRUE,null));
}
public void testAdaptNull() throws Exception {
@@ -85,7 +84,7 @@
}
public void testAdapt() throws Exception {
- assertNotNull(RightBoundPredicate.bind(new Constant(false),"xyzzy"));
- assertNotNull(RightBoundPredicate.bind(new Constant(false),null));
+ assertNotNull(RightBoundPredicate.bind(Constant.FALSE,"xyzzy"));
+ assertNotNull(RightBoundPredicate.bind(Constant.FALSE,null));
}
}