Author: scolebourne Date: Wed Jan 3 16:10:13 2007 New Revision: 492361 URL: http://svn.apache.org/viewvc?view=rev&rev=492361 Log: LANG-310 - BooleanUtils isNotTrue/isNotFalse
Modified: jakarta/commons/proper/lang/trunk/RELEASE-NOTES.txt jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/BooleanUtils.java jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/BooleanUtilsTest.java Modified: jakarta/commons/proper/lang/trunk/RELEASE-NOTES.txt URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/RELEASE-NOTES.txt?view=diff&rev=492361&r1=492360&r2=492361 ============================================================================== --- jakarta/commons/proper/lang/trunk/RELEASE-NOTES.txt (original) +++ jakarta/commons/proper/lang/trunk/RELEASE-NOTES.txt Wed Jan 3 16:10:13 2007 @@ -81,4 +81,5 @@ * [LANG-291] - Null-safe comparison methods for finding most recent / least recent dates. * [LANG-282] - Create more tests to test out the +=31 replacement code in DurationFormatUtils. * [LANG-266] - Wish for StringUtils.join(Collection, *) + * [LANG-310] - BooleanUtils isNotTrue/isNotFalse Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/BooleanUtils.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/BooleanUtils.java?view=diff&rev=492361&r1=492360&r2=492361 ============================================================================== --- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/BooleanUtils.java (original) +++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/BooleanUtils.java Wed Jan 3 16:10:13 2007 @@ -70,7 +70,8 @@ // boolean Boolean methods //----------------------------------------------------------------------- /** - * <p>Is a Boolean value <code>true</code>, handling <code>null</code>.</p> + * <p>Checks if a <code>Boolean</code> value is <code>true</code>, + * handling <code>null</code> by returning <code>false</code>.</p> * * <pre> * BooleanUtils.isTrue(Boolean.TRUE) = true @@ -78,7 +79,7 @@ * BooleanUtils.isTrue(null) = false * </pre> * - * @param bool the boolean to convert + * @param bool the boolean to check, null returns <code>false</code> * @return <code>true</code> only if the input is non-null and true * @since 2.1 */ @@ -90,7 +91,26 @@ } /** - * <p>Is a Boolean value <code>false</code>, handling <code>null</code>.</p> + * <p>Checks if a <code>Boolean</code> value is <i>not</i> <code>true</code>, + * handling <code>null</code> by returning <code>true</code>.</p> + * + * <pre> + * BooleanUtils.isNotTrue(Boolean.TRUE) = false + * BooleanUtils.isNotTrue(Boolean.FALSE) = true + * BooleanUtils.isNotTrue(null) = true + * </pre> + * + * @param bool the boolean to check, null returns <code>true</code> + * @return <code>true</code> if the input is null or false + * @since 2.3 + */ + public static boolean isNotTrue(Boolean bool) { + return !isTrue(bool); + } + + /** + * <p>Checks if a <code>Boolean</code> value is <code>false</code>, + * handling <code>null</code> by returning <code>false</code>.</p> * * <pre> * BooleanUtils.isFalse(Boolean.TRUE) = false @@ -98,7 +118,7 @@ * BooleanUtils.isFalse(null) = false * </pre> * - * @param bool the boolean to convert + * @param bool the boolean to check, null returns <code>false</code> * @return <code>true</code> only if the input is non-null and false * @since 2.1 */ @@ -109,6 +129,25 @@ return bool.booleanValue() ? false : true; } + /** + * <p>Checks if a <code>Boolean</code> value is <i>not</i> <code>false</code>, + * handling <code>null</code> by returning <code>true</code>.</p> + * + * <pre> + * BooleanUtils.isNotTrue(Boolean.TRUE) = true + * BooleanUtils.isNotTrue(Boolean.FALSE) = false + * BooleanUtils.isNotTrue(null) = true + * </pre> + * + * @param bool the boolean to check, null returns <code>true</code> + * @return <code>true</code> if the input is null or true + * @since 2.3 + */ + public static boolean isNotFalse(Boolean bool) { + return !isFalse(bool); + } + + //----------------------------------------------------------------------- /** * <p>Boolean factory that avoids creating new Boolean objecs all the time.</p> * Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/BooleanUtilsTest.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/BooleanUtilsTest.java?view=diff&rev=492361&r1=492360&r2=492361 ============================================================================== --- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/BooleanUtilsTest.java (original) +++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/BooleanUtilsTest.java Wed Jan 3 16:10:13 2007 @@ -79,10 +79,23 @@ assertEquals(false, BooleanUtils.isTrue((Boolean) null)); } + public void test_isNotTrue_Boolean() { + assertEquals(false, BooleanUtils.isNotTrue(Boolean.TRUE)); + assertEquals(true, BooleanUtils.isNotTrue(Boolean.FALSE)); + assertEquals(true, BooleanUtils.isNotTrue((Boolean) null)); + } + + //----------------------------------------------------------------------- public void test_isFalse_Boolean() { assertEquals(false, BooleanUtils.isFalse(Boolean.TRUE)); assertEquals(true, BooleanUtils.isFalse(Boolean.FALSE)); assertEquals(false, BooleanUtils.isFalse((Boolean) null)); + } + + public void test_isNotFalse_Boolean() { + assertEquals(true, BooleanUtils.isNotFalse(Boolean.TRUE)); + assertEquals(false, BooleanUtils.isNotFalse(Boolean.FALSE)); + assertEquals(true, BooleanUtils.isNotFalse((Boolean) null)); } //----------------------------------------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]