Interface OptionalFunction<I,O>
-
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface OptionalFunction<I,O> extends Function<I,Optional<? extends O>>
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description static <I,O>
OptionalFunction<I,O>empty()
default Function<I,O>
fallback(Function<? super I,? extends O> fallback)
Create a function which will fall back to the return values fromfallback
when this function doesn't return a value.static <I,O>
OptionalFunction<I,O>of(Object input, Supplier<? extends O> output)
static <I,O>
OptionalFunction<I,O>of(Object input, O output)
static <I,O>
OptionalFunction<I,O>of(Map<? super I,? extends O> map)
default OptionalFunction<I,O>
override(OptionalFunction<? super I,? extends O> override)
Create a optional function where any value returned fromoverride
overrides the value this function would return.
-
-
-
Method Detail
-
empty
static <I,O> OptionalFunction<I,O> empty()
-
of
static <I,O> OptionalFunction<I,O> of(Map<? super I,? extends O> map)
-
of
static <I,O> OptionalFunction<I,O> of(Object input, O output)
-
of
static <I,O> OptionalFunction<I,O> of(Object input, Supplier<? extends O> output)
-
fallback
default Function<I,O> fallback(Function<? super I,? extends O> fallback)
Create a function which will fall back to the return values fromfallback
when this function doesn't return a value.- Parameters:
fallback
- The function to call back to whenthis
returns no value.- Returns:
- A function which will return values from
this
or, if needed, the fallback. - See Also:
IOptionalFunctional.fallback(Function)
-
override
default OptionalFunction<I,O> override(OptionalFunction<? super I,? extends O> override)
Create a optional function where any value returned fromoverride
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:
IOptionalFunctional.override(IOptionalFunctional)
-
-