I want to prepend a stream with an Optional. Since Stream.concat can only concatinate Streams I have this question:
How do I convert an Optional
If you're on an older version of Java (lookin' at you, Android) and are using the aNNiMON Lightweight Stream API, you can do something along the lines of the following:
final List flintstones = new ArrayList(){{
add("Fred");
add("Wilma");
add("Pebbles");
}};
final List another = Optional.ofNullable(flintstones)
.map(Stream::of)
.orElseGet(Stream::empty)
.toList();
This example just makes a copy of the list.