Interface IOptionalFunction<I,O>
-
- All Superinterfaces:
Consumer<I>
,Function<I,IOptional<? extends O>>
,IConsumer
,IConsumer1<I>
,IFunction<IOptional<? extends O>>
,IFunction1<I,IOptional<? extends O>>
,IFunctional
,IOptionalFunctional<I,O,IOptionalFunction<? super I,? extends O>>
,IThrowConsumer1<I,RuntimeException>
,IThrowFunction1<I,IOptional<? extends O>,RuntimeException>
- All Known Implementing Classes:
IOptionalFunction.Empty
,IOptionalFunction.Overridden
,IOptionalFunction.Recursive
,IOptionalFunction.Restricted
- 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 IOptionalFunction<I,O> extends IFunction1<I,IOptional<? extends O>>, IOptionalFunctional<I,O,IOptionalFunction<? super I,? extends O>>
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
IOptionalFunction.Empty<I,O>
static class
IOptionalFunction.Overridden<I,O>
static class
IOptionalFunction.Recursive<I,O>
static class
IOptionalFunction.Restricted<I,O>
-
Nested classes/interfaces inherited from interface com.g2forge.alexandria.java.function.IFunction1
IFunction1.Identity<T>
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description static <I,O>
IOptionalFunction<I,O>empty(IOptionalFactory factory)
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>
IOptionalFunction<I,O>of(IOptionalFactory factory, IPredicate2<? super I,? super I> equals, I input, Supplier<? extends O> output)
static <I,O>
IOptionalFunction<I,O>of(IOptionalFactory factory, IPredicate2<? super I,? super I> equals, I input, O output)
static <I,O>
IOptionalFunction<I,O>of(IOptionalFactory factory, I input, Supplier<? extends O> output)
static <I,O>
IOptionalFunction<I,O>of(IOptionalFactory factory, I input, O output)
static <I,O>
IOptionalFunction<I,O>of(IOptionalFactory factory, Map<? super I,? extends O> map)
default IOptionalFunction<I,O>
override(IOptionalFunction<? super I,? extends O> override)
Create a function where any value returned fromoverride
overrides the value this function would return.default IOptionalFunction<I,O>
recursive(BiPredicate<? super I,? super I> terminate, boolean prior, Class<I> type)
default IOptionalFunction<I,O>
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.-
Methods inherited from interface com.g2forge.alexandria.java.function.IConsumer1
andThen
-
Methods inherited from interface com.g2forge.alexandria.java.function.IFunction1
accept, andThen, applyWithFallback, compose, curry, lift, lift, noReturn, override, sync, toConsumer, toFunction, wrap
-
Methods inherited from interface com.g2forge.alexandria.java.function.IThrowFunction1
apply, wrap
-
-
-
-
Method Detail
-
empty
static <I,O> IOptionalFunction<I,O> empty(IOptionalFactory factory)
-
of
static <I,O> IOptionalFunction<I,O> of(IOptionalFactory factory, I input, O output)
-
of
static <I,O> IOptionalFunction<I,O> of(IOptionalFactory factory, I input, Supplier<? extends O> output)
-
of
static <I,O> IOptionalFunction<I,O> of(IOptionalFactory factory, IPredicate2<? super I,? super I> equals, I input, O output)
-
of
static <I,O> IOptionalFunction<I,O> of(IOptionalFactory factory, IPredicate2<? super I,? super I> equals, I input, Supplier<? extends O> output)
-
of
static <I,O> IOptionalFunction<I,O> of(IOptionalFactory factory, Map<? super I,? extends O> map)
-
fallback
default Function<I,O> fallback(Function<? super I,? extends O> fallback)
Description copied from interface:IOptionalFunctional
Create a function which will fall back to the return values fromfallback
when this function doesn't return a value.- Specified by:
fallback
in interfaceIOptionalFunctional<I,O,IOptionalFunction<? super I,? extends O>>
- 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.override(IOptionalFunctional)
-
override
default IOptionalFunction<I,O> override(IOptionalFunction<? super I,? extends O> override)
Description copied from interface:IOptionalFunctional
Create a function where any value returned fromoverride
overrides the value this function would return.- Specified by:
override
in interfaceIOptionalFunctional<I,O,IOptionalFunction<? super I,? extends O>>
- 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.fallback(Function)
-
recursive
default IOptionalFunction<I,O> recursive(BiPredicate<? super I,? super I> terminate, boolean prior, Class<I> type)
- Specified by:
recursive
in interfaceIOptionalFunctional<I,O,IOptionalFunction<? super I,? extends O>>
-
restrict
default IOptionalFunction<I,O> restrict(Predicate<? super I> predicate, IOptionalFactory factory)
Description copied from interface:IOptionalFunctional
Create a function which returns an empty value for all of those not accepted by the specified predicate.- Specified by:
restrict
in interfaceIOptionalFunctional<I,O,IOptionalFunction<? super I,? extends O>>
- Parameters:
predicate
- When the predicate accepts an input, return the value fromthis
(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, andIOptionalFactory.empty()
otherwise.
-
-