com.machinezoo.noexception.optional

Interface OptionalSupplier<T>

NoException » API Reference » com.machinezoo.noexception.optional

    • Method Detail

      • orElse

        default Supplier<T> orElse(T result)
        Convert this OptionalSupplier to plain Supplier using default value. The returned Supplier will unwrap present value from the Optional if possible, or return result if the Optional is empty.
        Parameters:
        result - default value to return instead of an empty Optional
        Returns:
        plain Supplier that either unwraps Optional or returns default value
        See Also:
        orElseGet(Supplier), Optional.orElse(Object)
      • orElseGet

        default Supplier<T> orElseGet(Supplier<T> source)
        Convert this OptionalSupplier to plain Supplier using fallback Supplier. The returned Supplier will unwrap present value from the Optional if possible, or fall back to calling source if the Optional is empty.
        Parameters:
        source - Supplier to query for fallback value when Optional is empty
        Returns:
        plain Supplier that either unwraps Optional or falls back to source
        See Also:
        orElse(Object), Optional.orElseGet(Supplier)