commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang BooleanUtils.java
Date Sun, 22 Dec 2002 21:33:13 GMT
scolebourne    2002/12/22 13:33:12

  Modified:    lang/src/test/org/apache/commons/lang BooleanUtilsTest.java
               lang/src/java/org/apache/commons/lang BooleanUtils.java
  Log:
  Add negate(Boolean) method
  
  Revision  Changes    Path
  1.2       +8 -1      jakarta-commons/lang/src/test/org/apache/commons/lang/BooleanUtilsTest.java
  
  Index: BooleanUtilsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/BooleanUtilsTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BooleanUtilsTest.java	15 Dec 2002 16:55:32 -0000	1.1
  +++ BooleanUtilsTest.java	22 Dec 2002 21:33:12 -0000	1.2
  @@ -88,6 +88,13 @@
       }
   
       //-----------------------------------------------------------------------
  +    public void test_negate_Boolean() {
  +        assertSame(null, BooleanUtils.negate(null));
  +        assertSame(Boolean.TRUE, BooleanUtils.negate(Boolean.FALSE));
  +        assertSame(Boolean.FALSE, BooleanUtils.negate(Boolean.TRUE));
  +    }
  +
  +    //-----------------------------------------------------------------------
       public void test_toBooleanObject_boolean() {
           assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject(true));
           assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject(false));
  
  
  
  1.2       +19 -1     jakarta-commons/lang/src/java/org/apache/commons/lang/BooleanUtils.java
  
  Index: BooleanUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/BooleanUtils.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BooleanUtils.java	15 Dec 2002 16:55:32 -0000	1.1
  +++ BooleanUtils.java	22 Dec 2002 21:33:12 -0000	1.2
  @@ -72,6 +72,24 @@
       public BooleanUtils() {
       }
   
  +    // Boolean utilities
  +    //--------------------------------------------------------------------------
  +    
  +    /**
  +     * <p>Negates the specified boolean.</p>
  +     * 
  +     * <p>If <code>null</code> is passed in, <code>null</code>
will be returned.</p>
  +     * 
  +     * @param bool  the Boolean to negate, may be null
  +     * @return the negated Boolean, or <code>null</code> if <code>null</code>
passed in
  +     */
  +    public static Boolean negate(Boolean bool) {
  +        if (bool == null) {
  +            return null;
  +        }
  +        return (bool.booleanValue() ? Boolean.FALSE : Boolean.TRUE);
  +    }
  +    
       // boolean Boolean methods
       //--------------------------------------------------------------------------
       
  
  
  

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


Mime
View raw message