Return-Path: Delivered-To: apmail-commons-commits-archive@locus.apache.org Received: (qmail 83587 invoked from network); 10 Jun 2008 13:52:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Jun 2008 13:52:56 -0000 Received: (qmail 60828 invoked by uid 500); 10 Jun 2008 13:52:59 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 60395 invoked by uid 500); 10 Jun 2008 13:52:58 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 60385 invoked by uid 99); 10 Jun 2008 13:52:58 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jun 2008 06:52:58 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jun 2008 13:52:12 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 60B2A2388888; Tue, 10 Jun 2008 06:52:00 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r666110 - in /commons/sandbox/functor/trunk/src: main/java/org/apache/commons/functor/core/composite/BinaryNot.java test/java/org/apache/commons/functor/core/composite/TestBinaryNot.java Date: Tue, 10 Jun 2008 13:52:00 -0000 To: commits@commons.apache.org From: mbenson@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080610135200.60B2A2388888@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mbenson Date: Tue Jun 10 06:51:59 2008 New Revision: 666110 URL: http://svn.apache.org/viewvc?rev=666110&view=rev Log: IllegalArgumentException on null constructor argument Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryNot.java commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryNot.java Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryNot.java URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryNot.java?rev=666110&r1=666109&r2=666110&view=diff ============================================================================== --- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryNot.java (original) +++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryNot.java Tue Jun 10 06:51:59 2008 @@ -37,16 +37,19 @@ public final class BinaryNot implements BinaryPredicate, Serializable { // attributes // ------------------------------------------------------------------------ - private BinaryPredicate predicate = null; + private BinaryPredicate predicate; // constructor // ------------------------------------------------------------------------ /** * Create a new BinaryNot. - * @param p BinaryPredicate to negate + * @param predicate BinaryPredicate to negate */ - public BinaryNot(BinaryPredicate p) { - this.predicate = p; + public BinaryNot(BinaryPredicate predicate) { + if (predicate == null) { + throw new IllegalArgumentException("BinaryPredicate argument was null"); + } + this.predicate = predicate; } // predicate interface Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryNot.java URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryNot.java?rev=666110&r1=666109&r2=666110&view=diff ============================================================================== --- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryNot.java (original) +++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryNot.java Tue Jun 10 06:51:59 2008 @@ -44,7 +44,7 @@ // ------------------------------------------------------------------------ protected Object makeFunctor() { - return new BinaryNot(new Constant(true)); + return new BinaryNot(Constant.TRUE); } // Lifecycle @@ -62,20 +62,19 @@ // ------------------------------------------------------------------------ public void testTest() throws Exception { - BinaryPredicate truePred = new BinaryNot(new Constant(false)); + BinaryPredicate truePred = new BinaryNot(Constant.FALSE); assertTrue(truePred.test(null,null)); assertTrue(truePred.test("xyzzy","abcde")); assertTrue(truePred.test("xyzzy",new Integer(3))); } public void testEquals() throws Exception { - BinaryNot p = new BinaryNot(Constant.truePredicate()); + BinaryNot p = new BinaryNot(Constant.TRUE); assertEquals(p,p); - assertObjectsAreEqual(p,new BinaryNot(new Constant(true))); - assertObjectsAreEqual(p,BinaryNot.not(new Constant(true))); - assertObjectsAreNotEqual(p,new BinaryNot(new Constant(false))); - assertObjectsAreNotEqual(p,Constant.truePredicate()); - assertObjectsAreNotEqual(p,new BinaryNot(null)); + assertObjectsAreEqual(p,new BinaryNot(Constant.TRUE)); + assertObjectsAreEqual(p,BinaryNot.not(Constant.TRUE)); + assertObjectsAreNotEqual(p,new BinaryNot(Constant.FALSE)); + assertObjectsAreNotEqual(p,Constant.TRUE); } public void testNotNull() throws Exception {