diff --git a/pom.xml b/pom.xml index e3c2f7042fd..b1e6bfc01e3 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ 4.0.0 commons-lang3 - 3.12-SNAPSHOT + 3.12.0-SNAPSHOT Apache Commons Lang 2001 @@ -47,7 +47,7 @@ scm:git:http://gitbox.apache.org/repos/asf/commons-lang.git scm:git:https://gitbox.apache.org/repos/asf/commons-lang.git https://gitbox.apache.org/repos/asf?p=commons-lang.git - commons-lang-3.12 + commons-lang-3.12.0 @@ -587,7 +587,7 @@ lang3 org.apache.commons.lang3 - 3.12 + 3.12.0 (Java 8+) 2.6 @@ -624,7 +624,7 @@ 0.14.3 - 3.10 + 3.11 RC2 true scm:svn:https://dist.apache.org/repos/dist/dev/commons/lang diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 90fa7f55410..e624fc0ffa4 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -45,11 +45,14 @@ The type attribute can be add,update,fix,remove. - + Correct implementation of RandomUtils.nextLong(long, long) Restore handling of collections for non-JSON ToStringStyle #610. ContextedException Javadoc add missing semicolon #581. + + Add BooleanUtils.booleanValues(). + Add BooleanUtils.primitiveValues(). StringUtils.countMatches - clarify Javadoc. Remove redundant argument from substring call. diff --git a/src/main/java/org/apache/commons/lang3/BooleanUtils.java b/src/main/java/org/apache/commons/lang3/BooleanUtils.java index 39338538975..7b8885e3de0 100644 --- a/src/main/java/org/apache/commons/lang3/BooleanUtils.java +++ b/src/main/java/org/apache/commons/lang3/BooleanUtils.java @@ -99,6 +99,15 @@ public static Boolean and(final Boolean... array) { } } + /** + * Returns a new array of possible values (like an enum would). + * @return a new array of possible values (like an enum would). + * @since 3.12.0 + */ + public static Boolean[] booleanValues() { + return new Boolean[] {Boolean.FALSE, Boolean.TRUE}; + } + /** *

Compares two {@code boolean} values. This is the same functionality as provided in Java 7.

* @@ -280,6 +289,15 @@ public static Boolean or(final Boolean... array) { } } + /** + * Returns a new array of possible values (like an enum would). + * @return a new array of possible values (like an enum would). + * @since 3.12.0 + */ + public static boolean[] primitiveValues() { + return new boolean[] {false, true}; + } + /** *

Converts a Boolean to a boolean handling {@code null} * by returning {@code false}.

diff --git a/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java b/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java index 8920e851935..6eb6d1cefb5 100644 --- a/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java @@ -16,6 +16,7 @@ */ package org.apache.commons.lang3; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -26,6 +27,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; +import java.util.Arrays; import org.junit.jupiter.api.Test; @@ -34,6 +36,13 @@ */ public class BooleanUtilsTest { + @Test + public void test_booleanValues() { + final Boolean[] expected = new Boolean[] {false, true}; + Arrays.sort(expected); + assertArrayEquals(expected, BooleanUtils.booleanValues()); + } + @Test public void test_isFalse_Boolean() { assertFalse(BooleanUtils.isFalse(Boolean.TRUE)); @@ -69,6 +78,11 @@ public void test_negate_Boolean() { assertSame(Boolean.FALSE, BooleanUtils.negate(Boolean.TRUE)); } + @Test + public void test_primitiveValues() { + assertArrayEquals(new boolean[] {false, true}, BooleanUtils.primitiveValues()); + } + @Test public void test_toBoolean_Boolean() { assertTrue(BooleanUtils.toBoolean(Boolean.TRUE));