commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwaldh...@apache.org
Subject cvs commit: jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example FlexiMapExample.java
Date Tue, 02 Dec 2003 16:50:53 GMT
rwaldhoff    2003/12/02 08:50:53

  Modified:    functor/src/test/org/apache/commons/functor/core
                        TestLeftIdentity.java
                        TestRightIdentityFunction.java TestAll.java
                        TestRightIdentityPredicate.java
               functor/src/test/org/apache/commons/functor/adapter
                        TestLeftBoundFunction.java
                        TestLeftBoundProcedure.java
                        TestLeftBoundPredicate.java
                        TestRightBoundFunction.java
               functor/src/test/org/apache/commons/functor/example/kata/four
                        DataMunger.java
               functor/src/java/org/apache/commons/functor/core
                        RightIdentityFunction.java
                        RightIdentityPredicate.java
               functor/src/test/org/apache/commons/functor/core/composite
                        TestBinaryCompositeBinaryFunction.java
                        TestUnaryCompositeBinaryFunction.java
                        TestTransposedFunction.java
               functor/src/test/org/apache/commons/functor/example
                        FlexiMapExample.java
  Added:       functor/src/test/org/apache/commons/functor/core
                        TestRightIdentity.java
               functor/src/java/org/apache/commons/functor/core
                        RightIdentity.java
  Log:
  deprecate RightIdentityPredicate and RightIdentityFunction in favor of simply RightIdentity
  
  Revision  Changes    Path
  1.2       +3 -2      jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestLeftIdentity.java
  
  Index: TestLeftIdentity.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestLeftIdentity.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestLeftIdentity.java	2 Dec 2003 16:38:45 -0000	1.1
  +++ TestLeftIdentity.java	2 Dec 2003 16:50:52 -0000	1.2
  @@ -136,6 +136,7 @@
           assertEquals(f,f);
           assertObjectsAreEqual(f,new LeftIdentity());
           assertObjectsAreEqual(f,LeftIdentity.instance());
  +        assertObjectsAreNotEqual(f,new RightIdentity());
           assertObjectsAreNotEqual(f,new ConstantFunction("abcde"));
           assertObjectsAreNotEqual(f,new ConstantPredicate(true));
       }
  
  
  
  1.4       +3 -2      jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestRightIdentityFunction.java
  
  Index: TestRightIdentityFunction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestRightIdentityFunction.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestRightIdentityFunction.java	24 Nov 2003 20:12:15 -0000	1.3
  +++ TestRightIdentityFunction.java	2 Dec 2003 16:50:52 -0000	1.4
  @@ -65,6 +65,7 @@
   /**
    * @version $Revision$ $Date$
    * @author Rodney Waldhoff
  + * @deprecated
    */
   public class TestRightIdentityFunction extends BaseFunctorTest {
   
  
  
  
  1.10      +3 -2      jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestAll.java
  
  Index: TestAll.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestAll.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TestAll.java	2 Dec 2003 16:38:45 -0000	1.9
  +++ TestAll.java	2 Dec 2003 16:50:52 -0000	1.10
  @@ -77,6 +77,7 @@
           suite.addTest(TestNoOp.suite());
           suite.addTest(TestIdentityFunction.suite());
           suite.addTest(TestLeftIdentity.suite());
  +        suite.addTest(TestRightIdentity.suite());
           suite.addTest(TestLeftIdentityFunction.suite());
           suite.addTest(TestRightIdentityFunction.suite());
           suite.addTest(TestIsInstanceOf.suite());
  
  
  
  1.3       +3 -2      jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestRightIdentityPredicate.java
  
  Index: TestRightIdentityPredicate.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestRightIdentityPredicate.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestRightIdentityPredicate.java	24 Nov 2003 20:12:15 -0000	1.2
  +++ TestRightIdentityPredicate.java	2 Dec 2003 16:50:52 -0000	1.3
  @@ -65,6 +65,7 @@
   /**
    * @version $Revision$ $Date$
    * @author Rodney Waldhoff
  + * @deprecated
    */
   public class TestRightIdentityPredicate extends BaseFunctorTest {
   
  
  
  
  1.1                  jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestRightIdentity.java
  
  Index: TestRightIdentity.java
  ===================================================================
  /* 
   * $Header: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestRightIdentity.java,v
1.1 2003/12/02 16:50:52 rwaldhoff Exp $
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived 
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.functor.core;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  import org.apache.commons.functor.BaseFunctorTest;
  import org.apache.commons.functor.BinaryFunction;
  import org.apache.commons.functor.BinaryPredicate;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/12/02 16:50:52 $
   * @author Rodney Waldhoff
   */
  public class TestRightIdentity extends BaseFunctorTest {
  
      // Conventional
      // ------------------------------------------------------------------------
  
      public TestRightIdentity(String testName) {
          super(testName);
      }
  
      public static Test suite() {
          return new TestSuite(TestRightIdentity.class);
      }
  
      // Functor Testing Framework
      // ------------------------------------------------------------------------
  
      protected Object makeFunctor() {
          return new RightIdentity();
      }
      
      // Lifecycle
      // ------------------------------------------------------------------------
  
      public void setUp() throws Exception {
          super.setUp();
      }
  
      public void tearDown() throws Exception {
          super.tearDown();
      }
  
      // Tests
      // ------------------------------------------------------------------------
      
      public void testEvaluate() throws Exception {
          BinaryFunction f = new RightIdentity();
          assertNull(f.evaluate(null,null));
          assertNull(f.evaluate("xyzzy",null));
          assertEquals("xyzzy",f.evaluate("abcdefg","xyzzy"));
          assertEquals("xyzzy",f.evaluate(null,"xyzzy"));
          assertEquals(new Integer(3),f.evaluate(null,new Integer(3)));
          Object obj = new Long(12345L);
          assertSame(obj,f.evaluate(null,obj));
          assertSame(obj,f.evaluate(obj,obj));
      }
      
      public void testTest() throws Exception {
          BinaryPredicate p = new RightIdentity();
          assertTrue(p.test(null,Boolean.TRUE));
          assertTrue(!p.test(null,Boolean.FALSE));
          try {
              p.test(null,"true");
              fail("Expected ClassCastException");
          } catch(ClassCastException e) {
              // expected
          }
          try {
              p.test(null,null);
              fail("Expected NullPointerException");
          } catch(NullPointerException e) {
              // expected
          }
      }
      
      public void testEquals() throws Exception {
          BinaryFunction f = new RightIdentity();
          assertEquals(f,f);
          assertObjectsAreEqual(f,new RightIdentity());
          assertObjectsAreEqual(f,RightIdentity.instance());
          assertObjectsAreNotEqual(f,new IdentityPredicate());
          assertObjectsAreNotEqual(f,new LeftIdentity());
          assertObjectsAreNotEqual(f,new ConstantPredicate(true));
          assertObjectsAreNotEqual(f,new ConstantFunction("abcde"));
      }
      
      public void testConstant() throws Exception {
          assertEquals(RightIdentity.instance(),RightIdentity.instance());
          assertSame(RightIdentity.instance(),RightIdentity.instance());
      }
  }
  
  
  
  1.5       +11 -11    jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/adapter/TestLeftBoundFunction.java
  
  Index: TestLeftBoundFunction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/adapter/TestLeftBoundFunction.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestLeftBoundFunction.java	2 Dec 2003 16:38:45 -0000	1.4
  +++ TestLeftBoundFunction.java	2 Dec 2003 16:50:52 -0000	1.5
  @@ -63,7 +63,7 @@
   import org.apache.commons.functor.UnaryFunction;
   import org.apache.commons.functor.core.ConstantFunction;
   import org.apache.commons.functor.core.LeftIdentity;
  -import org.apache.commons.functor.core.RightIdentityFunction;
  +import org.apache.commons.functor.core.RightIdentity;
   
   /**
    * @version $Revision$ $Date$
  @@ -86,7 +86,7 @@
       // ------------------------------------------------------------------------
   
       protected Object makeFunctor() {
  -        return new LeftBoundFunction(new RightIdentityFunction(),"xyzzy");
  +        return new LeftBoundFunction(new RightIdentity(),"xyzzy");
       }
   
       // Lifecycle
  @@ -104,19 +104,19 @@
       // ------------------------------------------------------------------------    
   
       public void testEvaluate() throws Exception {
  -        UnaryFunction f = new LeftBoundFunction(new RightIdentityFunction(),"foo");
  +        UnaryFunction f = new LeftBoundFunction(new RightIdentity(),"foo");
           assertEquals("xyzzy",f.evaluate("xyzzy"));
       }
       
       public void testEquals() throws Exception {
  -        UnaryFunction f = new LeftBoundFunction(new RightIdentityFunction(),"xyzzy");
  +        UnaryFunction f = new LeftBoundFunction(new RightIdentity(),"xyzzy");
           assertEquals(f,f);
  -        assertObjectsAreEqual(f,new LeftBoundFunction(new RightIdentityFunction(),"xyzzy"));
  +        assertObjectsAreEqual(f,new LeftBoundFunction(new RightIdentity(),"xyzzy"));
           assertObjectsAreNotEqual(f,new ConstantFunction("xyzzy"));
           assertObjectsAreNotEqual(f,new LeftBoundFunction(new LeftIdentity(),"xyzzy"));
  -        assertObjectsAreNotEqual(f,new LeftBoundFunction(new RightIdentityFunction(),"bar"));
  +        assertObjectsAreNotEqual(f,new LeftBoundFunction(new RightIdentity(),"bar"));
           assertObjectsAreNotEqual(f,new LeftBoundFunction(null,"xyzzy"));
  -        assertObjectsAreNotEqual(f,new LeftBoundFunction(new RightIdentityFunction(),null));
  +        assertObjectsAreNotEqual(f,new LeftBoundFunction(new RightIdentity(),null));
           assertObjectsAreEqual(new LeftBoundFunction(null,null),new LeftBoundFunction(null,null));
       }
   
  @@ -125,7 +125,7 @@
       }
   
       public void testAdapt() throws Exception {
  -        assertNotNull(LeftBoundFunction.bind(new RightIdentityFunction(),"xyzzy"));
  -        assertNotNull(LeftBoundFunction.bind(new RightIdentityFunction(),null));
  +        assertNotNull(LeftBoundFunction.bind(new RightIdentity(),"xyzzy"));
  +        assertNotNull(LeftBoundFunction.bind(new RightIdentity(),null));
       }
   }
  
  
  
  1.5       +5 -5      jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/adapter/TestLeftBoundProcedure.java
  
  Index: TestLeftBoundProcedure.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/adapter/TestLeftBoundProcedure.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestLeftBoundProcedure.java	4 Mar 2003 23:11:12 -0000	1.4
  +++ TestLeftBoundProcedure.java	2 Dec 2003 16:50:52 -0000	1.5
  @@ -62,7 +62,7 @@
   import org.apache.commons.functor.BaseFunctorTest;
   import org.apache.commons.functor.UnaryProcedure;
   import org.apache.commons.functor.core.NoOp;
  -import org.apache.commons.functor.core.RightIdentityFunction;
  +import org.apache.commons.functor.core.RightIdentity;
   
   /**
    * @version $Revision$ $Date$
  @@ -103,7 +103,7 @@
       // ------------------------------------------------------------------------    
   
       public void testRun() throws Exception {
  -        UnaryProcedure p = new LeftBoundProcedure(new BinaryFunctionBinaryProcedure(new
RightIdentityFunction()),"foo");
  +        UnaryProcedure p = new LeftBoundProcedure(new BinaryFunctionBinaryProcedure(new
RightIdentity()),"foo");
           p.run(Boolean.TRUE);
           p.run(Boolean.FALSE);
       }
  @@ -113,7 +113,7 @@
           assertEquals(f,f);
           assertObjectsAreEqual(f,new LeftBoundProcedure(new NoOp(),"xyzzy"));
           assertObjectsAreNotEqual(f,new NoOp());        
  -        assertObjectsAreNotEqual(f,new LeftBoundProcedure(new BinaryFunctionBinaryProcedure(new
RightIdentityFunction()),"xyzzy"));
  +        assertObjectsAreNotEqual(f,new LeftBoundProcedure(new BinaryFunctionBinaryProcedure(new
RightIdentity()),"xyzzy"));
           assertObjectsAreNotEqual(f,new LeftBoundProcedure(new NoOp(),"foo"));
           assertObjectsAreNotEqual(f,new LeftBoundProcedure(null,"xyzzy"));
           assertObjectsAreNotEqual(f,new LeftBoundProcedure(new NoOp(),null));
  
  
  
  1.4       +4 -4      jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/adapter/TestLeftBoundPredicate.java
  
  Index: TestLeftBoundPredicate.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/adapter/TestLeftBoundPredicate.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestLeftBoundPredicate.java	4 Mar 2003 23:11:12 -0000	1.3
  +++ TestLeftBoundPredicate.java	2 Dec 2003 16:50:52 -0000	1.4
  @@ -62,7 +62,7 @@
   import org.apache.commons.functor.BaseFunctorTest;
   import org.apache.commons.functor.UnaryPredicate;
   import org.apache.commons.functor.core.ConstantPredicate;
  -import org.apache.commons.functor.core.RightIdentityFunction;
  +import org.apache.commons.functor.core.RightIdentity;
   
   /**
    * @version $Revision$ $Date$
  @@ -103,7 +103,7 @@
       // ------------------------------------------------------------------------    
   
       public void testTest() throws Exception {
  -        UnaryPredicate p = new LeftBoundPredicate(new BinaryFunctionBinaryPredicate(new
RightIdentityFunction()),"foo");
  +        UnaryPredicate p = new LeftBoundPredicate(new BinaryFunctionBinaryPredicate(new
RightIdentity()),"foo");
           assertEquals(true,p.test(Boolean.TRUE));
           assertEquals(false,p.test(Boolean.FALSE));
       }
  
  
  
  1.5       +4 -4      jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/adapter/TestRightBoundFunction.java
  
  Index: TestRightBoundFunction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/adapter/TestRightBoundFunction.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestRightBoundFunction.java	2 Dec 2003 16:38:45 -0000	1.4
  +++ TestRightBoundFunction.java	2 Dec 2003 16:50:52 -0000	1.5
  @@ -63,7 +63,7 @@
   import org.apache.commons.functor.UnaryFunction;
   import org.apache.commons.functor.core.ConstantFunction;
   import org.apache.commons.functor.core.LeftIdentity;
  -import org.apache.commons.functor.core.RightIdentityFunction;
  +import org.apache.commons.functor.core.RightIdentity;
   
   /**
    * @version $Revision$ $Date$
  @@ -113,7 +113,7 @@
           assertEquals(f,f);
           assertObjectsAreEqual(f,new RightBoundFunction(new LeftIdentity(),"xyzzy"));
           assertObjectsAreNotEqual(f,new ConstantFunction("xyzzy"));
  -        assertObjectsAreNotEqual(f,new RightBoundFunction(new RightIdentityFunction(),"xyzzy"));
  +        assertObjectsAreNotEqual(f,new RightBoundFunction(new RightIdentity(),"xyzzy"));
           assertObjectsAreNotEqual(f,new RightBoundFunction(new LeftIdentity(),"bar"));
           assertObjectsAreNotEqual(f,new RightBoundFunction(null,"xyzzy"));
           assertObjectsAreNotEqual(f,new RightBoundFunction(new LeftIdentity(),null));
  
  
  
  1.4       +5 -5      jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/kata/four/DataMunger.java
  
  Index: DataMunger.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/kata/four/DataMunger.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DataMunger.java	2 Dec 2003 16:38:45 -0000	1.3
  +++ DataMunger.java	2 Dec 2003 16:50:52 -0000	1.4
  @@ -72,7 +72,7 @@
   import org.apache.commons.functor.adapter.UnaryPredicateUnaryFunction;
   import org.apache.commons.functor.core.IsNull;
   import org.apache.commons.functor.core.LeftIdentity;
  -import org.apache.commons.functor.core.RightIdentityFunction;
  +import org.apache.commons.functor.core.RightIdentity;
   import org.apache.commons.functor.core.comparator.IsLessThan;
   import org.apache.commons.functor.core.composite.BinaryCompositeBinaryFunction;
   import org.apache.commons.functor.core.composite.CompositeUnaryFunction;
  @@ -112,7 +112,7 @@
       private static final BinaryFunction lesserSpread(final int col1, final int col2) {
           return new ConditionalBinaryFunction(            
               IgnoreRightPredicate.adapt(IsNull.instance()), // if left is null
  -            RightIdentityFunction.instance(),              // return right
  +            RightIdentity.instance(),              // return right
               new ConditionalBinaryFunction(                 // else calculate spread and
compare
                   BinaryFunctionBinaryPredicate.adapt(       
                       new BinaryCompositeBinaryFunction(
  @@ -120,7 +120,7 @@
                           IgnoreRightFunction.adapt(absSpread(col1,col2)),
                           IgnoreLeftFunction.adapt(absSpread(col1,col2)))),
                   LeftIdentity.instance(),
  -                RightIdentityFunction.instance()
  +                RightIdentity.instance()
               )
           );
       }
  
  
  
  1.4       +3 -2      jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/RightIdentityFunction.java
  
  Index: RightIdentityFunction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/RightIdentityFunction.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RightIdentityFunction.java	24 Nov 2003 20:12:16 -0000	1.3
  +++ RightIdentityFunction.java	2 Dec 2003 16:50:52 -0000	1.4
  @@ -65,6 +65,7 @@
    * 
    * @version $Revision$ $Date$
    * @author Rodney Waldhoff
  + * @deprecated Use {@link RightIdentity}
    */
   public final class RightIdentityFunction implements BinaryFunction, Serializable {
   
  
  
  
  1.3       +3 -2      jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/RightIdentityPredicate.java
  
  Index: RightIdentityPredicate.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/RightIdentityPredicate.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RightIdentityPredicate.java	24 Nov 2003 20:12:16 -0000	1.2
  +++ RightIdentityPredicate.java	2 Dec 2003 16:50:52 -0000	1.3
  @@ -69,6 +69,7 @@
    * 
    * @version $Revision$ $Date$
    * @author Rodney Waldhoff
  + * @deprecated Use {@link RightIdentity}
    */
   public final class RightIdentityPredicate implements BinaryPredicate, Serializable {
       
  
  
  
  1.1                  jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/RightIdentity.java
  
  Index: RightIdentity.java
  ===================================================================
  /* 
   * $Header: /home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/RightIdentity.java,v
1.1 2003/12/02 16:50:52 rwaldhoff Exp $
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived 
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.functor.core;
  
  import java.io.Serializable;
  
  import org.apache.commons.functor.BinaryFunction;
  import org.apache.commons.functor.BinaryPredicate;
  
  /**
   * {@link #evaluate Evaluates} to its second argument.
   * 
   * {@link #test Tests} to the <code>boolean</code>
   * value of the <code>Boolean</code>-valued second
   * argument. The {@link #test test} method 
   * throws an exception if the parameter isn't a 
   * non-<code>null</code> <code>Boolean</code>.
   * 
   * @version $Revision: 1.1 $ $Date: 2003/12/02 16:50:52 $
   * @author Rodney Waldhoff
   */
  public final class RightIdentity implements BinaryPredicate, BinaryFunction, Serializable
{
      
      // constructor
      // ------------------------------------------------------------------------
      public RightIdentity() {
      }
   
      // functor interface
      // ------------------------------------------------------------------------
  
      public Object evaluate(Object left, Object right) {
          return right;
      }
  
      public boolean test(Object left, Object right) {
          return test((Boolean)right);
      }
  
      private boolean test(Boolean bool) {
          return bool.booleanValue();
      }
  
      public boolean equals(Object that) {
          return (that instanceof RightIdentity);
      }
      
      public int hashCode() {
          return "RightIdentity".hashCode();
      }
      
      public String toString() {
          return "RightIdentity";
      }
      
      // static methods
      // ------------------------------------------------------------------------
      public static RightIdentity instance() {
          return INSTANCE;
      }
      
      // static attributes
      // ------------------------------------------------------------------------
      private static final RightIdentity INSTANCE = new RightIdentity();
  }
  
  
  
  1.4       +10 -10    jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/composite/TestBinaryCompositeBinaryFunction.java
  
  Index: TestBinaryCompositeBinaryFunction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/composite/TestBinaryCompositeBinaryFunction.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestBinaryCompositeBinaryFunction.java	2 Dec 2003 16:38:45 -0000	1.3
  +++ TestBinaryCompositeBinaryFunction.java	2 Dec 2003 16:50:53 -0000	1.4
  @@ -63,7 +63,7 @@
   import org.apache.commons.functor.BinaryFunction;
   import org.apache.commons.functor.core.ConstantFunction;
   import org.apache.commons.functor.core.LeftIdentity;
  -import org.apache.commons.functor.core.RightIdentityFunction;
  +import org.apache.commons.functor.core.RightIdentity;
   
   /**
    * @version $Revision$ $Date$
  @@ -87,9 +87,9 @@
   
       protected Object makeFunctor() {
           return new BinaryCompositeBinaryFunction(
  -            new RightIdentityFunction(),
  +            new RightIdentity(),
               new ConstantFunction("left"),
  -            new RightIdentityFunction());
  +            new RightIdentity());
       }
   
       // Lifecycle
  @@ -108,9 +108,9 @@
      
       public void testEvaluate() throws Exception {
           BinaryFunction f = new BinaryCompositeBinaryFunction(
  -            new RightIdentityFunction(),
  +            new RightIdentity(),
               new ConstantFunction("K"),
  -            new RightIdentityFunction());
  +            new RightIdentity());
           assertEquals("right",f.evaluate("left","right"));
           assertNull("right",f.evaluate("left",null));
           assertEquals("right",f.evaluate(null,"right"));
  @@ -127,17 +127,17 @@
               new ConstantFunction("left"),
               new ConstantFunction("right")));
           assertObjectsAreNotEqual(f,new BinaryCompositeBinaryFunction(
  -            new RightIdentityFunction(),
  +            new RightIdentity(),
               new ConstantFunction("left"),
               new ConstantFunction("right")));
           assertObjectsAreNotEqual(f,new BinaryCompositeBinaryFunction(
               new LeftIdentity(),
  -            new RightIdentityFunction(),
  +            new RightIdentity(),
               new ConstantFunction("right")));
           assertObjectsAreNotEqual(f,new BinaryCompositeBinaryFunction(
               new LeftIdentity(),
               new ConstantFunction("left"),
  -            new RightIdentityFunction()));
  +            new RightIdentity()));
           assertObjectsAreNotEqual(f,new BinaryCompositeBinaryFunction(null,null,null));
           assertObjectsAreEqual(
               new BinaryCompositeBinaryFunction(null,null,null),
  
  
  
  1.4       +6 -6      jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/composite/TestUnaryCompositeBinaryFunction.java
  
  Index: TestUnaryCompositeBinaryFunction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/composite/TestUnaryCompositeBinaryFunction.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestUnaryCompositeBinaryFunction.java	2 Dec 2003 16:38:45 -0000	1.3
  +++ TestUnaryCompositeBinaryFunction.java	2 Dec 2003 16:50:53 -0000	1.4
  @@ -64,7 +64,7 @@
   import org.apache.commons.functor.core.ConstantFunction;
   import org.apache.commons.functor.core.IdentityFunction;
   import org.apache.commons.functor.core.LeftIdentity;
  -import org.apache.commons.functor.core.RightIdentityFunction;
  +import org.apache.commons.functor.core.RightIdentity;
   
   /**
    * @version $Revision$ $Date$
  @@ -88,7 +88,7 @@
   
       protected Object makeFunctor() {
           return new UnaryCompositeBinaryFunction(
  -            new RightIdentityFunction(),
  +            new RightIdentity(),
               new ConstantFunction("left"),
               new IdentityFunction());
       }
  @@ -109,7 +109,7 @@
      
       public void testEvaluate() throws Exception {
           BinaryFunction f = new UnaryCompositeBinaryFunction(
  -            new RightIdentityFunction(),
  +            new RightIdentity(),
               new ConstantFunction("K"),
               new IdentityFunction());
           assertEquals("right",f.evaluate("left","right"));
  @@ -128,7 +128,7 @@
               new ConstantFunction("left"),
               new ConstantFunction("right")));
           assertObjectsAreNotEqual(f,new UnaryCompositeBinaryFunction(
  -            new RightIdentityFunction(),
  +            new RightIdentity(),
               new ConstantFunction("left"),
               new ConstantFunction("right")));
           assertObjectsAreNotEqual(f,new UnaryCompositeBinaryFunction(
  
  
  
  1.3       +4 -4      jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/composite/TestTransposedFunction.java
  
  Index: TestTransposedFunction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/composite/TestTransposedFunction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestTransposedFunction.java	2 Dec 2003 16:38:45 -0000	1.2
  +++ TestTransposedFunction.java	2 Dec 2003 16:50:53 -0000	1.3
  @@ -63,7 +63,7 @@
   import org.apache.commons.functor.BinaryFunction;
   import org.apache.commons.functor.core.ConstantFunction;
   import org.apache.commons.functor.core.LeftIdentity;
  -import org.apache.commons.functor.core.RightIdentityFunction;
  +import org.apache.commons.functor.core.RightIdentity;
   
   /**
    * @version $Revision$ $Date$
  @@ -113,7 +113,7 @@
           BinaryFunction f = new TransposedFunction(new LeftIdentity());
           assertEquals(f,f);
           assertObjectsAreEqual(f,new TransposedFunction(new LeftIdentity()));
  -        assertObjectsAreNotEqual(f,new TransposedFunction(new RightIdentityFunction()));
  +        assertObjectsAreNotEqual(f,new TransposedFunction(new RightIdentity()));
           assertObjectsAreNotEqual(f,new TransposedFunction(null));
           assertObjectsAreNotEqual(f,new ConstantFunction("y"));
       }
  
  
  
  1.7       +6 -6      jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/FlexiMapExample.java
  
  Index: FlexiMapExample.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/FlexiMapExample.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FlexiMapExample.java	24 Nov 2003 20:12:16 -0000	1.6
  +++ FlexiMapExample.java	2 Dec 2003 16:50:53 -0000	1.7
  @@ -78,7 +78,7 @@
   import org.apache.commons.functor.core.IdentityFunction;
   import org.apache.commons.functor.core.IsInstanceOf;
   import org.apache.commons.functor.core.IsNull;
  -import org.apache.commons.functor.core.RightIdentityFunction;
  +import org.apache.commons.functor.core.RightIdentity;
   import org.apache.commons.functor.core.composite.ConditionalUnaryFunction;
   
   /*
  @@ -329,13 +329,13 @@
            */
           public FlexiMap(BinaryFunction putfn, BinaryFunction getfn) {
               if(null == putfn) {
  -                onPut = new RightIdentityFunction();
  +                onPut = new RightIdentity();
               } else {
                   onPut = putfn;
               }
               
               if(null == getfn) {
  -                onGet = new RightIdentityFunction();
  +                onGet = new RightIdentity();
               } else {
                   onGet = getfn;
               }
  @@ -425,7 +425,7 @@
   
       /*
        * For the "basic" Map, we'll simply create a HashMap.
  -     * Note that using a RightIdentityFunction for onPut and onGet
  +     * Note that using a RightIdentity for onPut and onGet
        * would yield the same behavior. 
        */
       private Map makeBasicMap() {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message