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 152b1777fddc5127e77f9b14637d6abae18eaf05
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sat Jul 16 11:14:44 2022 -0400

    Rename new method
---
 .../org/apache/commons/lang3/stream/Streams.java   | 30 +++++++++---------
 .../apache/commons/lang3/stream/StreamsTest.java   | 36 +++++++++++-----------
 2 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/stream/Streams.java 
b/src/main/java/org/apache/commons/lang3/stream/Streams.java
index 720405129..eee85087e 100644
--- a/src/main/java/org/apache/commons/lang3/stream/Streams.java
+++ b/src/main/java/org/apache/commons/lang3/stream/Streams.java
@@ -530,7 +530,7 @@ public class Streams {
      * @since 3.13.0
      */
     public static <T> FailableStream<T> failableStream(final Collection<T> 
stream) {
-        return failableStream(toStream(stream));
+        return failableStream(of(stream));
     }
 
     /**
@@ -578,7 +578,7 @@ public class Streams {
     }
 
     private static <E> Stream<E> filter(final Collection<E> collection, final 
Predicate<? super E> predicate) {
-        return toStream(collection).filter(predicate);
+        return of(collection).filter(predicate);
     }
 
     /**
@@ -597,7 +597,7 @@ public class Streams {
      * @since 3.13.0
      */
     public static <E> Stream<E> instancesOf(final Class<? super E> clazz, 
final Collection<? super E> collection) {
-        return instancesOf(clazz, toStream(collection));
+        return instancesOf(clazz, of(collection));
     }
 
     @SuppressWarnings("unchecked") // After the isInstance check, we still 
need to type-cast.
@@ -617,6 +617,18 @@ public class Streams {
         return filter(collection, Objects::nonNull);
     }
 
+    /**
+     * Delegates to {@link Collection#stream()} or returns {@link 
Stream#empty()} if the collection is null.
+     *
+     * @param <E> the type of elements in the collection.
+     * @param collection the collection to stream or null.
+     * @return {@link Collection#stream()} or {@link Stream#empty()} if the 
collection is null.
+     * @since 3.13.0
+     */
+    public static <E> Stream<E> of(final Collection<E> collection) {
+        return collection == null ? Stream.empty() : collection.stream();
+    }
+
     /**
      * Streams the elements of the given enumeration in order.
      *
@@ -742,16 +754,4 @@ public class Streams {
     public static <T extends Object> Collector<T, ?, T[]> toArray(final 
Class<T> pElementType) {
         return new ArrayCollector<>(pElementType);
     }
-
-    /**
-     * Delegates to {@link Collection#stream()} or returns {@link 
Stream#empty()} if the collection is null.
-     *
-     * @param <E> the type of elements in the collection.
-     * @param collection the collection to stream or null.
-     * @return {@link Collection#stream()} or {@link Stream#empty()} if the 
collection is null.
-     * @since 3.13.0
-     */
-    public static <E> Stream<E> toStream(final Collection<E> collection) {
-        return collection == null ? Stream.empty() : collection.stream();
-    }
 }
diff --git a/src/test/java/org/apache/commons/lang3/stream/StreamsTest.java 
b/src/test/java/org/apache/commons/lang3/stream/StreamsTest.java
index 99b34204b..3db2ec794 100644
--- a/src/test/java/org/apache/commons/lang3/stream/StreamsTest.java
+++ b/src/test/java/org/apache/commons/lang3/stream/StreamsTest.java
@@ -133,13 +133,6 @@ public class StreamsTest extends AbstractLangTest {
             }));
     }
 
-    @Test
-    public void testNullSafeStreamNotNull() {
-        assertEquals(2, Streams.nonNull(Arrays.asList("A", 
"B")).collect(Collectors.toList()).size());
-        assertEquals(2, Streams.nonNull(Arrays.asList(null, "A", null, "B", 
null)).collect(Collectors.toList()).size());
-        assertEquals(0, Streams.nonNull(Arrays.asList(null, 
null)).collect(Collectors.toList()).size());
-    }
-
     @Test
     public void testInstanceOfStream() {
         assertEquals(2, Streams.instancesOf(String.class, Arrays.asList("A", 
"B")).collect(Collectors.toList()).size());
@@ -150,6 +143,13 @@ public class StreamsTest extends AbstractLangTest {
         assertEquals(2, Streams.instancesOf(String.class, 
objects).collect(Collectors.toList()).size());
     }
 
+    @Test
+    public void testNullSafeStreamNotNull() {
+        assertEquals(2, Streams.nonNull(Arrays.asList("A", 
"B")).collect(Collectors.toList()).size());
+        assertEquals(2, Streams.nonNull(Arrays.asList(null, "A", null, "B", 
null)).collect(Collectors.toList()).size());
+        assertEquals(0, Streams.nonNull(Arrays.asList(null, 
null)).collect(Collectors.toList()).size());
+    }
+
     @Test
     public void testNullSafeStreamNull() {
         final List<String> input = null;
@@ -163,6 +163,17 @@ public class StreamsTest extends AbstractLangTest {
         assertEquals(2, Streams.of("foo", "bar").count());
     }
 
+    @Test
+    public void testOfCollectionNotNull() {
+        assertEquals(2, Streams.of(Arrays.asList("A", 
"B")).collect(Collectors.toList()).size());
+    }
+
+    @Test
+    public void testOfCollectionNull() {
+        final List<String> input = null;
+        assertEquals(0, Streams.of(input).collect(Collectors.toList()).size());
+    }
+
     @Test
     public void testOfEnumeration() {
         final Hashtable<String, Integer> table = new Hashtable<>();
@@ -235,15 +246,4 @@ public class StreamsTest extends AbstractLangTest {
         assertEquals("1", array[2]);
     }
 
-    @Test
-    public void testToStreamNotNull() {
-        assertEquals(2, Streams.toStream(Arrays.asList("A", 
"B")).collect(Collectors.toList()).size());
-    }
-
-    @Test
-    public void testToStreamNull() {
-        final List<String> input = null;
-        assertEquals(0, 
Streams.toStream(input).collect(Collectors.toList()).size());
-    }
-
 }

Reply via email to