Add Streams.failableStream(T), non-varargs variant
This commit is contained in:
parent
c9c1e222b8
commit
b9c7da0a8c
|
@ -53,6 +53,7 @@ The <action> type attribute can be add,update,fix,remove.
|
|||
<action issue="LANG-1724" type="add" dev="ggregory" due-to="Gary Gregory">Add ReflectionDiffBuilder.Builder.</action>
|
||||
<action issue="LANG-1724" type="add" dev="ggregory" due-to="Gary Gregory">Add ReflectionDiffBuilder.builder().</action>
|
||||
<action issue="LANG-1702" type="add" dev="ggregory" due-to="Elliotte Rusty Harold">Add test in TypeUtilsTest #1151.</action>
|
||||
<action issue="LANG-1724" type="add" dev="ggregory" due-to="Gary Gregory">Add Streams.failableStream(T), non-varargs variant.</action>
|
||||
<!-- FIX -->
|
||||
<action type="fix" dev="ggregory" due-to="Miklós Karakó, Gary Gregory">Improve Javadoc in ExceptionUtils #1136.</action>
|
||||
<action type="fix" dev="ggregory" due-to="Saiharshith Karuneegar Ramesh, Gary Gregory">Fixed two non-deterministic tests in EnumUtilsTest.java #1131.</action>
|
||||
|
|
|
@ -579,6 +579,18 @@ public class Streams {
|
|||
return new FailableStream<>(stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shorthand for {@code Streams.failableStream(value == null ? Stream.empty() : Stream.of(value))}.
|
||||
*
|
||||
* @param <T> the type of stream elements.
|
||||
* @param value the single element of the new stream, may be {@code null}.
|
||||
* @return the new FailableStream on {@code value} or an empty stream.
|
||||
* @since 3.15.0
|
||||
*/
|
||||
public static <T> FailableStream<T> failableStream(final T value) {
|
||||
return failableStream(value == null ? Stream.empty() : Stream.of(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Shorthand for {@code Streams.failableStream(Streams.of(arrayValues))}.
|
||||
*
|
||||
|
|
|
@ -60,6 +60,10 @@ public class FailableStreamTest {
|
|||
return Streams.failableStream(strings).map(this::failable).collect(Collectors.toList()).toArray(new String[0]);
|
||||
}
|
||||
|
||||
private String[] toArray(final String string) {
|
||||
return Streams.failableStream(string).map(this::failable).collect(Collectors.toList()).toArray(new String[0]);
|
||||
}
|
||||
|
||||
private String[] toArray(final String... strings) {
|
||||
return Streams.failableStream(strings).map(this::failable).collect(Collectors.toList()).toArray(new String[0]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue