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 2019/08/22 14:33:34 UTC

[commons-lang] branch master updated (2f38c4b -> dbd4766)

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

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


    from 2f38c4b  Sort members.
     new 561fc60  junit-jupiter 5.5.0 -> 5.5.1.
     new 8a579f0  com.puppycrawl.tools:checkstyle 8.20 -> 8.23.
     new eacbb1f  Update properties for the next release.
     new 8a192eb  commons.japicmp.version 0.13.1 -> 0.14.1.
     new b1d01fe  [LANG-1479] Add Range.fit(T) to fit a value into a range.
     new dbd4766  Fix typo.

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pom.xml                                            | 12 ++++++------
 src/changes/changes.xml                            |  3 ++-
 src/main/java/org/apache/commons/lang3/Range.java  | 22 ++++++++++++++++++++++
 .../java/org/apache/commons/lang3/RangeTest.java   | 17 ++++++++++++++++-
 4 files changed, 46 insertions(+), 8 deletions(-)


[commons-lang] 05/06: [LANG-1479] Add Range.fit(T) to fit a value into a range.

Posted by gg...@apache.org.
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

commit b1d01fecee3b347b2488eb34bd33c90db0847399
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Aug 22 10:33:05 2019 -0400

    [LANG-1479] Add Range.fit(T) to fit a value into a range.
---
 src/changes/changes.xml                            |  1 +
 src/main/java/org/apache/commons/lang3/Range.java  | 22 ++++++++++++++++++++++
 .../java/org/apache/commons/lang3/RangeTest.java   | 17 ++++++++++++++++-
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 905a7b2..45c58a4 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -56,6 +56,7 @@ The <action> type attribute can be add,update,fix,remove.
     <action issue="LANG-1437" type="update" dev="ggregory" due-to="Andrei Troie">Remove redundant if statements in join methods #411.</action>
     <action issue="LANG-1460" type="fix" dev="kinow" due-to="Larry West">Trivial: year of release for 3.9 says 2018, should be 2019</action>
     <action issue="LANG-1476" type="fix" dev="kinow" due-to="emopers">Use synchronise on a set created with Collections.synchronizedSet before iterating</action>
+    <action issue="LANG-1479" type="add" dev="ggregory">Add Range.fit(T) to fit a value into a range.</action>
   </release>
 
   <release version="3.9" date="2019-04-09" description="New features and bug fixes. Requires Java 8, supports Java 9, 10, 11">
diff --git a/src/main/java/org/apache/commons/lang3/Range.java b/src/main/java/org/apache/commons/lang3/Range.java
index 4f3da66..449be0c 100644
--- a/src/main/java/org/apache/commons/lang3/Range.java
+++ b/src/main/java/org/apache/commons/lang3/Range.java
@@ -453,6 +453,28 @@ public final class Range<T> implements Serializable {
     }
 
     /**
+     * <p>
+     * Fits the given element into this range by returning the given element or, if out of bounds, the range minimum if
+     * below, or the range maximum if above.
+     * </p>
+     *
+     * @param element the element to check for, not null
+     * @return the minimum, the element, or the maximum depending on the element's location relative to the range
+     * @since 3.10
+     */
+    public T fit(final T element) {
+        // Comparable API says throw NPE on null
+        Validate.notNull(element, "Element is null");
+        if (isAfter(element)) {
+            return minimum;
+        } else if (isBefore(element)) {
+            return maximum;
+        } else {
+            return element;
+        }
+    }
+
+    /**
      * <p>Gets the range as a {@code String}.</p>
      *
      * <p>The format of the String is '[<i>min</i>..<i>max</i>]'.</p>
diff --git a/src/test/java/org/apache/commons/lang3/RangeTest.java b/src/test/java/org/apache/commons/lang3/RangeTest.java
index 4705115..29b9967 100644
--- a/src/test/java/org/apache/commons/lang3/RangeTest.java
+++ b/src/test/java/org/apache/commons/lang3/RangeTest.java
@@ -171,6 +171,22 @@ public class RangeTest {
     }
 
     @Test
+    public void testFit() {
+        assertEquals(intRange.getMinimum(), intRange.fit(Integer.MIN_VALUE));
+        assertEquals(intRange.getMinimum(), intRange.fit(intRange.getMinimum()));
+        assertEquals(intRange.getMaximum(), intRange.fit(Integer.MAX_VALUE));
+        assertEquals(intRange.getMaximum(), intRange.fit(intRange.getMaximum()));
+        assertEquals(15, intRange.fit(15));
+    }
+
+    @Test
+    public void testFitNull() {
+        assertThrows(NullPointerException.class, () -> {
+            intRange.fit(null);
+        });
+    }
+
+    @Test
     public void testGetMaximum() {
         assertEquals(20, (int) intRange.getMaximum());
         assertEquals(20L, (long) longRange.getMaximum());
@@ -367,5 +383,4 @@ public class RangeTest {
         final String str = intRange.toString("From %1$s to %2$s");
         assertEquals("From 10 to 20", str);
     }
-
 }


[commons-lang] 02/06: com.puppycrawl.tools:checkstyle 8.20 -> 8.23.

Posted by gg...@apache.org.
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

commit 8a579f0c773046d0acececcc7557b08765ed86a4
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Aug 22 10:17:41 2019 -0400

    com.puppycrawl.tools:checkstyle 8.20 -> 8.23.
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 007bd55..1910027 100644
--- a/pom.xml
+++ b/pom.xml
@@ -597,7 +597,7 @@
     <commons.encoding>utf-8</commons.encoding>
 
     <checkstyle.plugin.version>3.0.0</checkstyle.plugin.version>
-    <checkstyle.version>8.20</checkstyle.version>
+    <checkstyle.version>8.23</checkstyle.version>
 
     <spotbugs.plugin.version>3.1.11</spotbugs.plugin.version>
     <japicmp.skip>false</japicmp.skip>


[commons-lang] 01/06: junit-jupiter 5.5.0 -> 5.5.1.

Posted by gg...@apache.org.
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

commit 561fc60c635e6a9a097bea30412603ad3a862e73
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Aug 22 10:17:00 2019 -0400

    junit-jupiter 5.5.0 -> 5.5.1.
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index a19f591..007bd55 100644
--- a/pom.xml
+++ b/pom.xml
@@ -513,7 +513,7 @@
     <dependency>
       <groupId>org.junit.jupiter</groupId>
       <artifactId>junit-jupiter</artifactId>
-      <version>5.5.0</version>
+      <version>5.5.1</version>
       <scope>test</scope>
     </dependency>
     <dependency>


[commons-lang] 03/06: Update properties for the next release.

Posted by gg...@apache.org.
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

commit eacbb1f8d5da1c913d775b40ab74b86d4d4ef794
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Aug 22 10:18:21 2019 -0400

    Update properties for the next release.
---
 pom.xml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml
index 1910027..127f546 100644
--- a/pom.xml
+++ b/pom.xml
@@ -581,7 +581,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.9</commons.release.version>
+    <commons.release.version>3.10</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>
@@ -615,8 +615,8 @@
     <commons.japicmp.version>0.13.1</commons.japicmp.version>
 
     <!-- Commons Release Plugin -->
-    <commons.bc.version>3.8.1</commons.bc.version>
-    <commons.rc.version>RC2</commons.rc.version>
+    <commons.bc.version>3.9</commons.bc.version>
+    <commons.rc.version>RC1</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>
     <commons.releaseManagerName>Rob Tompkins</commons.releaseManagerName>


[commons-lang] 04/06: commons.japicmp.version 0.13.1 -> 0.14.1.

Posted by gg...@apache.org.
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

commit 8a192eb6b57357c925a41eac18f760f3e11d9f42
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Aug 22 10:32:44 2019 -0400

    commons.japicmp.version 0.13.1 -> 0.14.1.
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 127f546..0ae407d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -612,7 +612,7 @@
 
     <!-- generate report even if there are binary incompatible changes -->
     <commons.japicmp.breakBuildOnBinaryIncompatibleModifications>false</commons.japicmp.breakBuildOnBinaryIncompatibleModifications>
-    <commons.japicmp.version>0.13.1</commons.japicmp.version>
+    <commons.japicmp.version>0.14.1</commons.japicmp.version>
 
     <!-- Commons Release Plugin -->
     <commons.bc.version>3.9</commons.bc.version>


[commons-lang] 06/06: Fix typo.

Posted by gg...@apache.org.
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

commit dbd4766cfd7bcc0eb62b28d9b7ea23f22a5d6471
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Aug 22 10:33:29 2019 -0400

    Fix typo.
---
 src/changes/changes.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 45c58a4..f7801fd 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -55,7 +55,7 @@ The <action> type attribute can be add,update,fix,remove.
     <action issue="LANG-1470" type="add" dev="ggregory">Add ArrayUtils.addFirst() methods.</action>
     <action issue="LANG-1437" type="update" dev="ggregory" due-to="Andrei Troie">Remove redundant if statements in join methods #411.</action>
     <action issue="LANG-1460" type="fix" dev="kinow" due-to="Larry West">Trivial: year of release for 3.9 says 2018, should be 2019</action>
-    <action issue="LANG-1476" type="fix" dev="kinow" due-to="emopers">Use synchronise on a set created with Collections.synchronizedSet before iterating</action>
+    <action issue="LANG-1476" type="fix" dev="kinow" due-to="emopers">Use synchronize on a set created with Collections.synchronizedSet before iterating</action>
     <action issue="LANG-1479" type="add" dev="ggregory">Add Range.fit(T) to fit a value into a range.</action>
   </release>