Class Optionals.Either<T>

  • Enclosing class:
    Optionals

    public static class Optionals.Either<T>
    extends Object
    Wrapper around an Optional that offers Java 9's Optional#or method.
    • Method Detail

      • or

        public Optional<T> or​(Supplier<? extends Optional<? extends T>> supplier)
        If a value is present, returns an Optional describing the value, otherwise returns an Optional produced by the supplying function.
        Parameters:
        supplier - the supplying function that produces an Optional to be returned
        Returns:
        returns an Optional describing the value of this Optional, if a value is present, otherwise an Optional produced by the supplying function.
        Throws:
        NullPointerException - if the supplying function is null or produces a null result