You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by da...@apache.org on 2024/10/13 08:31:01 UTC

(jackrabbit-oak) branch OAK-11188 created (now 7f7eccb855)

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

daim pushed a change to branch OAK-11188
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git


      at 7f7eccb855 OAK-11188 : added api to create treeSet from iterables

This branch includes the following new commits:

     new 7f7eccb855 OAK-11188 : added api to create treeSet from iterables

The 1 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.



(jackrabbit-oak) 01/01: OAK-11188 : added api to create treeSet from iterables

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

daim pushed a commit to branch OAK-11188
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git

commit 7f7eccb85505f224f47a167de2f3ea3af29c8f0b
Author: Rishabh Kumar <di...@adobe.com>
AuthorDate: Sun Oct 13 14:00:44 2024 +0530

    OAK-11188 : added api to create treeSet from iterables
---
 .../oak/commons/collections/CollectionUtils.java          | 15 +++++++++++++++
 .../jackrabbit/oak/commons/collections/package-info.java  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtils.java b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtils.java
index f49d0b7908..abe02dbcd0 100644
--- a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtils.java
+++ b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/CollectionUtils.java
@@ -27,6 +27,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
+import java.util.TreeSet;
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
 
@@ -101,6 +102,20 @@ public class CollectionUtils {
         return result;
     }
 
+    /**
+     * Convert an iterable to a {@link java.util.TreeSet}. The returning set is mutable and supports all optional operations.
+     * @param iterable the iterable to convert
+     * @return the treeSet
+     * @param <T> the type of the elements
+     */
+    @NotNull
+    public static <T extends Comparable> TreeSet<T> toTreeSet(@NotNull  final Iterable<? extends T> iterable) {
+        Objects.requireNonNull(iterable);
+        final TreeSet<T> result = new TreeSet<>();
+        iterable.forEach(result::add);
+        return result;
+    }
+
     /**
      * Convert an iterator to a set. The returning set is mutable and supports all optional operations.
      * @param iterator the iterator to convert
diff --git a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/package-info.java b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/package-info.java
index 04c54891f1..11a3fa317b 100644
--- a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/package-info.java
+++ b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/package-info.java
@@ -21,7 +21,7 @@
  * Utilities for Java collections and streams.
  */
 @Internal(since = "1.0.0")
-@Version("1.1.0")
+@Version("1.2.0")
 package org.apache.jackrabbit.oak.commons.collections;
 import org.apache.jackrabbit.oak.commons.annotations.Internal;
 import org.osgi.annotation.versioning.Version;