Interface IOptionalFunctional<I,​O,​F extends IOptionalFunctional<? super I,​? extends O,​?>>

    • Method Detail

      • fallback

        Function<I,​O> fallback​(Function<? super I,​? extends O> fallback)
        Create a function which will fall back to the return values from fallback when this function doesn't return a value.
        Parameters:
        fallback - The function to call back to when this returns no value.
        Returns:
        A function which will return values from this or, if needed, the fallback.
        See Also:
        override(IOptionalFunctional)
      • override

        IOptionalFunctional<I,​O,​F> override​(F override)
        Create a function where any value returned from override overrides the value this function would return.
        Parameters:
        override - The function whose return values, when any, override our own.
        Returns:
        An optional function which returns the results of override if any, and the result of this optional function otherwise.
        See Also:
        fallback(Function)
      • restrict

        IOptionalFunctional<I,​O,​F> restrict​(Predicate<? super I> predicate,
                                                        IOptionalFactory factory)
        Create a function which returns an empty value for all of those not accepted by the specified predicate.
        Parameters:
        predicate - When the predicate accepts an input, return the value from this (whether empty or not).
        factory - An optional factory, necessary to construct the necessary empty values when the predicate does not accept an input.
        Returns:
        An optional functional which returns the same values as this when the predicate accepts an input, and IOptionalFactory.empty() otherwise.