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 2024/10/14 10:40:31 UTC

(commons-lang) branch master updated (5059d190d -> e852e8088)

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 5059d190d docs: fix broken URL to project location in Maven Central (#1296)
     new 4830e09b1 Javadoc
     new 798caa4e5 Add LongRange.toLongStream()
     new e852e8088 Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-lang.git

The 3 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:
 src/changes/changes.xml                               |  1 +
 src/main/java/org/apache/commons/lang3/LongRange.java | 19 ++++++++++++++++---
 .../java/org/apache/commons/lang3/LongRangeTest.java  |  8 ++++++++
 3 files changed, 25 insertions(+), 3 deletions(-)


(commons-lang) 01/03: Javadoc

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 4830e09b1c1e89212ca6f60fea29acaedfa6ba9e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Oct 13 10:31:27 2024 -0400

    Javadoc
---
 src/main/java/org/apache/commons/lang3/LongRange.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/LongRange.java b/src/main/java/org/apache/commons/lang3/LongRange.java
index ec1639557..ef6493dec 100644
--- a/src/main/java/org/apache/commons/lang3/LongRange.java
+++ b/src/main/java/org/apache/commons/lang3/LongRange.java
@@ -31,7 +31,7 @@ public final class LongRange extends NumberRange<Long> {
     private static final long serialVersionUID = 1L;
 
     /**
-     * Creates a range with the specified minimum and maximum values (both inclusive).
+     * Creates a closed range with the specified minimum and maximum values (both inclusive).
      *
      * <p>
      * The range uses the natural ordering of the elements to determine where values lie in the range.
@@ -50,7 +50,7 @@ public final class LongRange extends NumberRange<Long> {
     }
 
     /**
-     * Creates a range with the specified minimum and maximum values (both inclusive).
+     * Creates a closed range with the specified minimum and maximum values (both inclusive).
      *
      * <p>
      * The range uses the natural ordering of the elements to determine where values lie in the range.


(commons-lang) 02/03: Add LongRange.toLongStream()

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 798caa4e51747dfbfceba0af8db7afa4fe629e36
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Oct 13 10:34:04 2024 -0400

    Add LongRange.toLongStream()
---
 src/changes/changes.xml                                   |  1 +
 src/main/java/org/apache/commons/lang3/LongRange.java     | 15 ++++++++++++++-
 src/test/java/org/apache/commons/lang3/LongRangeTest.java |  8 ++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 369a4908b..fb517e3bb 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -63,6 +63,7 @@ The <action> type attribute can be add,update,fix,remove.
     <action                   type="add" dev="ggregory" due-to="Gary Gregory">Add JavaVersion.JAVA_23.</action>
     <action                   type="add" dev="ggregory" due-to="Gary Gregory">Add SystemUtils.IS_JAVA_23.</action>
     <action                   type="add" dev="ggregory" due-to="Gary Gregory">Add IntegerRange.toIntStream().</action>
+    <action                   type="add" dev="ggregory" due-to="Gary Gregory">Add LongRange.toLongStream().</action>
     <!-- UPDATE -->
     <action                   type="update" dev="ggregory" due-to="Gary Gregory, Dependabot">Bump org.apache.commons:commons-parent from 73 to 77 #1267, #1277, #1283, #1288.</action>
   </release>
diff --git a/src/main/java/org/apache/commons/lang3/LongRange.java b/src/main/java/org/apache/commons/lang3/LongRange.java
index ef6493dec..f4b504571 100644
--- a/src/main/java/org/apache/commons/lang3/LongRange.java
+++ b/src/main/java/org/apache/commons/lang3/LongRange.java
@@ -17,6 +17,8 @@
 
 package org.apache.commons.lang3;
 
+import java.util.stream.LongStream;
+
 /**
  * Specializes {@link NumberRange} for {@link Long}s.
  *
@@ -70,7 +72,7 @@ public final class LongRange extends NumberRange<Long> {
     }
 
     /**
-     * Creates an instance.
+     * Creates a new instance.
      *
      * @param number1 the first element, not null
      * @param number2 the second element, not null
@@ -81,4 +83,15 @@ public final class LongRange extends NumberRange<Long> {
         super(number1, number2, null);
     }
 
+    /**
+     * Returns a sequential ordered {@code LongStream} from {@link #getMinimum()} (inclusive) to {@link #getMaximum()} (inclusive) by an incremental step of
+     * {@code 1}.
+     *
+     * @return a sequential {@code LongStream} for the range of {@code long} elements
+     * @since 3.18.0
+     */
+    public LongStream toLongStream() {
+        return LongStream.rangeClosed(getMinimum(), getMaximum());
+    }
+
 }
diff --git a/src/test/java/org/apache/commons/lang3/LongRangeTest.java b/src/test/java/org/apache/commons/lang3/LongRangeTest.java
index 290ce8a00..cc7a6002e 100644
--- a/src/test/java/org/apache/commons/lang3/LongRangeTest.java
+++ b/src/test/java/org/apache/commons/lang3/LongRangeTest.java
@@ -26,6 +26,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Comparator;
+import java.util.stream.LongStream;
 
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -409,6 +410,13 @@ public class LongRangeTest extends AbstractLangTest {
         SerializationUtils.clone(range1);
     }
 
+    @Test
+    public void testToIntStream() {
+        try (LongStream stream = range1.toLongStream()) {
+            assertEquals(165, stream.sum());
+        }
+    }
+
     @Test
     public void testToString() {
         assertNotNull(range1.toString());


(commons-lang) 03/03: Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-lang.git

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 e852e8088e0485e2214efe0f10400aa9d931eaef
Merge: 798caa4e5 5059d190d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Oct 14 06:40:10 2024 -0400

    Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-lang.git

 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)