package yokohama.unit.util;

import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Stream;

public class Optionals {
    public static <T, U> U match(Optional<T> optional, Supplier<U> none, Function<? super T, U> some) {
        return optional.isPresent() ? some.apply(optional.get()) : none.get();
    }

    public static <T> Stream<T> toStream(Optional<T> optional) {
        return optional.isPresent() ? Stream.of(optional.get()) : Stream.empty();
    }
}

@@ -536,12 +536,151 @@
 %0D%0A    %7D%0D
+%0A%0D%0A    public static %3CT%3E Optional%3CT%3E fromNullable(T value) %7B%0D%0A        return value == null ? Optional.empty() : Optional.of(value);%0D%0A    %7D%0D
 %0A%7D%0D%0A

Add Optionals.fromNullable utility method