mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-08 11:05:09 +00:00
Rename method for next release.
This commit is contained in:
parent
9f0f3c838b
commit
46b15a2ecb
@ -561,14 +561,14 @@ private static <E> Stream<E> instancesOf(final Class<? super E> clazz, final Str
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Streams non-null elements of a collection.
|
* Streams the non-null elements of a collection.
|
||||||
*
|
*
|
||||||
* @param <E> the type of elements in the collection.
|
* @param <E> the type of elements in the collection.
|
||||||
* @param collection the collection to stream or null.
|
* @param collection the collection to stream or null.
|
||||||
* @return A non-null stream that filters out null elements.
|
* @return A non-null stream that filters out null elements.
|
||||||
* @since 3.13.0
|
* @since 3.13.0
|
||||||
*/
|
*/
|
||||||
public static <E> Stream<E> nullSafeStream(final Collection<E> collection) {
|
public static <E> Stream<E> nonNull(final Collection<E> collection) {
|
||||||
return filter(collection, Objects::nonNull);
|
return filter(collection, Objects::nonNull);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,9 +133,9 @@ public Stream<DynamicTest> simpleStreamForEachFailing() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNullSafeStreamNotNull() {
|
public void testNullSafeStreamNotNull() {
|
||||||
assertEquals(2, Streams.nullSafeStream(Arrays.asList("A", "B")).collect(Collectors.toList()).size());
|
assertEquals(2, Streams.nonNull(Arrays.asList("A", "B")).collect(Collectors.toList()).size());
|
||||||
assertEquals(2, Streams.nullSafeStream(Arrays.asList(null, "A", null, "B", null)).collect(Collectors.toList()).size());
|
assertEquals(2, Streams.nonNull(Arrays.asList(null, "A", null, "B", null)).collect(Collectors.toList()).size());
|
||||||
assertEquals(0, Streams.nullSafeStream(Arrays.asList(null, null)).collect(Collectors.toList()).size());
|
assertEquals(0, Streams.nonNull(Arrays.asList(null, null)).collect(Collectors.toList()).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -151,7 +151,7 @@ public void testInstanceOfStream() {
|
|||||||
@Test
|
@Test
|
||||||
public void testNullSafeStreamNull() {
|
public void testNullSafeStreamNull() {
|
||||||
final List<String> input = null;
|
final List<String> input = null;
|
||||||
assertEquals(0, Streams.nullSafeStream(input).collect(Collectors.toList()).size());
|
assertEquals(0, Streams.nonNull(input).collect(Collectors.toList()).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user