You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/09/28 19:32:02 UTC

[commons-lang] branch master updated: Add BooleanUtils.booleanValues(). Add BooleanUtils.primitiveValues().

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git


The following commit(s) were added to refs/heads/master by this push:
     new b2e7374  Add BooleanUtils.booleanValues(). Add BooleanUtils.primitiveValues().
b2e7374 is described below

commit b2e7374bfb91b54d49dfb4d327de639ff1f4b127
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Sep 28 15:31:56 2020 -0400

    Add BooleanUtils.booleanValues().
    Add BooleanUtils.primitiveValues().
    
    Handy for tools and tests.
    Make next release version 3.12.0.
---
 pom.xml                                                |  8 ++++----
 src/changes/changes.xml                                |  5 ++++-
 .../java/org/apache/commons/lang3/BooleanUtils.java    | 18 ++++++++++++++++++
 .../org/apache/commons/lang3/BooleanUtilsTest.java     | 14 ++++++++++++++
 4 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/pom.xml b/pom.xml
index e3c2f70..b1e6bfc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <artifactId>commons-lang3</artifactId>
-  <version>3.12-SNAPSHOT</version>
+  <version>3.12.0-SNAPSHOT</version>
   <name>Apache Commons Lang</name>
 
   <inceptionYear>2001</inceptionYear>
@@ -47,7 +47,7 @@
     <connection>scm:git:http://gitbox.apache.org/repos/asf/commons-lang.git</connection>
     <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/commons-lang.git</developerConnection>
     <url>https://gitbox.apache.org/repos/asf?p=commons-lang.git</url>
-    <tag>commons-lang-3.12</tag>
+    <tag>commons-lang-3.12.0</tag>
   </scm>
 
   <developers>
@@ -587,7 +587,7 @@
     <commons.packageId>lang3</commons.packageId>
     <commons.module.name>org.apache.commons.lang3</commons.module.name>
     <!-- Current 3.x release series -->
-    <commons.release.version>3.12</commons.release.version>
+    <commons.release.version>3.12.0</commons.release.version>
     <commons.release.desc>(Java 8+)</commons.release.desc>
     <!-- Previous 2.x release series -->
     <commons.release.2.version>2.6</commons.release.2.version>
@@ -624,7 +624,7 @@
     <commons.japicmp.version>0.14.3</commons.japicmp.version>
 
     <!-- Commons Release Plugin -->
-    <commons.bc.version>3.10</commons.bc.version>
+    <commons.bc.version>3.11</commons.bc.version>
     <commons.rc.version>RC2</commons.rc.version>
     <commons.release.isDistModule>true</commons.release.isDistModule>
     <commons.distSvnStagingUrl>scm:svn:https://dist.apache.org/repos/dist/dev/commons/lang</commons.distSvnStagingUrl>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 90fa7f5..e624fc0 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -45,11 +45,14 @@ The <action> type attribute can be add,update,fix,remove.
   </properties>
   <body>
 
-  <release version="3.12" date="2020-MM-DD" description="New features and bug fixes.">
+  <release version="3.12.0" date="2020-MM-DD" description="New features and bug fixes.">
     <!--  FIXES -->
     <action issue="LANG-1592" type="fix" dev="aherbert" due-to="Huang Pingcai, Alex Herbert">Correct implementation of RandomUtils.nextLong(long, long)</action>
     <action issue="LANG-1600" type="fix" dev="ggregory" due-to="Michael F">Restore handling of collections for non-JSON ToStringStyle #610.</action>
     <action                   type="fix" dev="ggregory" due-to="iamchao1129">ContextedException Javadoc add missing semicolon #581.</action>
+    <!--  ADDS -->
+    <action                   type="add" dev="ggregory" due-to="Gary Gregory">Add BooleanUtils.booleanValues().</action>
+    <action                   type="add" dev="ggregory" due-to="Gary Gregory">Add BooleanUtils.primitiveValues().</action>
     <!--  UPDATES -->
     <action issue="LANG-1606" type="update" dev="sebb" due-to="Rustem Galiev">StringUtils.countMatches - clarify Javadoc.</action>
     <action issue="LANG-1591" type="update" dev="kinow" due-to="bhawna94">Remove redundant argument from substring call.</action>
diff --git a/src/main/java/org/apache/commons/lang3/BooleanUtils.java b/src/main/java/org/apache/commons/lang3/BooleanUtils.java
index 3933853..7b8885e 100644
--- a/src/main/java/org/apache/commons/lang3/BooleanUtils.java
+++ b/src/main/java/org/apache/commons/lang3/BooleanUtils.java
@@ -100,6 +100,15 @@ public class BooleanUtils {
     }
 
     /**
+     * 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};
+    }
+
+    /**
      * <p>Compares two {@code boolean} values. This is the same functionality as provided in Java 7.</p>
      *
      * @param x the first {@code boolean} to compare
@@ -281,6 +290,15 @@ public class BooleanUtils {
     }
 
     /**
+     * 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};
+    }
+
+    /**
      * <p>Converts a Boolean to a boolean handling {@code null}
      * by returning {@code false}.</p>
      *
diff --git a/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java b/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java
index 8920e85..6eb6d1c 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 static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Modifier;
+import java.util.Arrays;
 
 import org.junit.jupiter.api.Test;
 
@@ -35,6 +37,13 @@ import org.junit.jupiter.api.Test;
 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));
         assertTrue(BooleanUtils.isFalse(Boolean.FALSE));
@@ -70,6 +79,11 @@ public class BooleanUtilsTest {
     }
 
     @Test
+    public void test_primitiveValues() {
+        assertArrayEquals(new boolean[] {false, true}, BooleanUtils.primitiveValues());
+    }
+
+    @Test
     public void test_toBoolean_Boolean() {
         assertTrue(BooleanUtils.toBoolean(Boolean.TRUE));
         assertFalse(BooleanUtils.toBoolean(Boolean.FALSE));