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));