R
- return typeP1
- parameter type 1P2
- parameter type 2@FunctionalInterface public interface Function2<R,P1,P2> extends java.util.function.BiFunction<P1,P2,R>, Function1<R,ITuple2<? extends P1,? extends P2>>
This is basically the same as BiFunction
,
but more extensible. As it extends BiFunction
it can be used
anywhere as a replacement.
Modifier and Type | Method and Description |
---|---|
default <FR extends ITuple2<? extends P1,? extends P2>,FP> |
after1(java.util.function.Function<FP,FR> before)
Get a chained function which first applies the given function, then this one.
|
default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2> |
after2(java.util.function.BiFunction<FP1,FP2,FR> before)
Get a chained function which first applies the given 2-parameter function, then this one.
|
default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3> |
after3(Function3<FR,FP1,FP2,FP3> before)
Get a chained function which first applies the given 3-parameter function, then this one.
|
default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5> |
after5(Function5<FR,FP1,FP2,FP3,FP4,FP5> before)
Get a chained function which first applies the given 5-parameter function, then this one.
|
default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5,FP6> |
after6(Function6<FR,FP1,FP2,FP3,FP4,FP5,FP6> before)
Get a chained function which first applies the given 6-parameter function, then this one.
|
default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5,FP6,FP7> |
after7(Function7<FR,FP1,FP2,FP3,FP4,FP5,FP6,FP7> before)
Get a chained function which first applies the given 7-parameter function, then this one.
|
default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8> |
after8(Function8<FR,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8> before)
Get a chained function which first applies the given 8-parameter function, then this one.
|
default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8,FP9> |
after9(Function9<FR,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8,FP9> before)
Get a chained function which first applies the given 9-parameter function, then this one.
|
default <T> Function2<T,P1,P2> |
andThen(java.util.function.Function<? super R,? extends T> after)
Get a chained function which first applies this function
and then the given function to the returned value.
|
default R |
apply(ITuple2<? extends P1,? extends P2> tuple2)
Expand a tuple into the arguments of this function.
|
default R |
applyOrDefault(P1 arg1,
P2 arg2,
R fallback)
Apply this function, but take care to create a fallback.
|
static <RR,PP1,PP2> |
from(java.util.function.BiFunction<PP1,PP2,RR> bifunc)
Make a standard
BiFunction usable as a Function2 . |
static <E extends java.lang.Exception,RR,PP1,PP2> |
nonFragile(FragileFunction2<? extends RR,E,? super PP1,? super PP2> fragileFunction)
Convert a 2-argument function which might throw a checked exception into
one which does throw an unchecked exception.
|
static <E extends java.lang.Exception,RR,PP1,PP2> |
nonFragile(FragileFunction2<? extends RR,E,? super PP1,? super PP2> fragileFunction,
RR fallback)
Convert a 2-argument function which might throw a checked exception into
one which will return a default value instead of throwing an exception.
|
static <E extends java.lang.Exception,RR,PP1,PP2> |
nonFragileX(FragileFunction2<? extends RR,E,? super PP1,? super PP2> fragileFunction,
Function3<? extends RR,? super E,? super PP1,? super PP2> exceptionHandler)
Convert a 2-argument function which might throw a checked exception into
one for which you can decide what happens with the exception.
|
default Function1<R,P2> |
partial1(P1 argument)
Get a partially applied function where the first argument is fix.
|
default Function1<R,P1> |
partial2(P2 argument)
Get a partially applied function where the second argument is fix.
|
default Function1<R,P2> |
partialLeft(P1 argument)
Get a partially applied function.
|
default Function1<R,P1> |
partialRight(P2 argument)
Get a partially applied function.
|
after, applyNonNull, applyOrDefault, fallback, fallback, from, from, nonFragile, nonFragile, nonFragileX, partial, withFallback
default R apply(@NotNull ITuple2<? extends P1,? extends P2> tuple2)
apply
in interface java.util.function.Function<ITuple2<? extends P1,? extends P2>,R>
tuple2
- tuple to expand, not null
. Use Types.notNull(Object, Object)
or
Objects.requireNonNull(Object)
if necessary,
or have a look at Types.notNull(Object, Object)
@NotNull default R applyOrDefault(P1 arg1, P2 arg2, @NotNull R fallback)
BiFunction.apply(Object, Object)
returns null
.arg1
- first argument of this functionarg2
- second argument of this functionfallback
- fallback value returned if function returns null
BiFunction.apply(Object, Object)
, or fallback
if the result was null
@NotNull default Function1<R,P2> partialLeft(P1 argument)
argument
- value applied for first argument@NotNull default Function1<R,P2> partial1(P1 argument)
partialLeft(Object)
but named more consistently.argument
- value applied for first argument@NotNull default Function1<R,P1> partialRight(P2 argument)
argument
- value applied for second argument@NotNull default Function1<R,P1> partial2(P2 argument)
argument
- value applied for second argument@NotNull default <T> Function2<T,P1,P2> andThen(@NotNull java.util.function.Function<? super R,? extends T> after)
andThen
in interface java.util.function.BiFunction<P1,P2,R>
andThen
in interface java.util.function.Function<ITuple2<? extends P1,? extends P2>,R>
andThen
in interface Function1<R,ITuple2<? extends P1,? extends P2>>
T
- result type of returned functionafter
- function to apply after this one@NotNull default <FR extends ITuple2<? extends P1,? extends P2>,FP> Function1<R,FP> after1(@NotNull java.util.function.Function<FP,FR> before)
ITuple2
with matching parametric types
which are applied in their order to this function.FR
- function before
's return type, has to be a 2-tuple with matching typesFP
- function before
's parameter type, same for returned functionbefore
- function to apply first, has to return a non-null
result so unpacking the parameters
from the tuple is possible@NotNull default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2> Function2<R,FP1,FP2> after2(@NotNull java.util.function.BiFunction<FP1,FP2,FR> before)
ITuple2
with matching parametric types
which are applied in their order to this function.FR
- function before
's return type, has to be a 2-tuple with matching typesFP1
- function before
's first parameter type, sane for returned functionFP2
- function before
's second parameter type, same for returned functionbefore
- function to apply first, has to return a non-null
result so unpacking the parameters
from the tuple is possible@NotNull default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3> Function3<R,FP1,FP2,FP3> after3(@NotNull Function3<FR,FP1,FP2,FP3> before)
ITuple2
with matching parametric types
which are applied in their order to this function.FR
- function before
's return type, has to be a 2-tuple with matching typesFP1
- function before
's first parameter type, sane for returned functionFP2
- function before
's second parameter type, sane for returned functionFP3
- function before
's third parameter type, sane for returned functionbefore
- function to apply first, has to return a non-null
result so unpacking the parameters
from the tuple is possible@NotNull default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5> Function5<R,FP1,FP2,FP3,FP4,FP5> after5(@NotNull Function5<FR,FP1,FP2,FP3,FP4,FP5> before)
ITuple2
with matching parametric types
which are applied in their order to this function.FR
- function before
's return type, has to be a 2-tuple with matching typesFP1
- function before
's first parameter type, sane for returned functionFP2
- function before
's second parameter type, sane for returned functionFP3
- function before
's third parameter type, sane for returned functionFP4
- function before
's fourth parameter type, sane for returned functionFP5
- function before
's fifth parameter type, sane for returned functionbefore
- function to apply first, has to return a non-null
result so unpacking the parameters
from the tuple is possible@NotNull default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5,FP6> Function6<R,FP1,FP2,FP3,FP4,FP5,FP6> after6(@NotNull Function6<FR,FP1,FP2,FP3,FP4,FP5,FP6> before)
ITuple2
with matching parametric types
which are applied in their order to this function.FR
- function before
's return type, has to be a 2-tuple with matching typesFP1
- function before
's first parameter type, sane for returned functionFP2
- function before
's second parameter type, sane for returned functionFP3
- function before
's third parameter type, sane for returned functionFP4
- function before
's fourth parameter type, sane for returned functionFP5
- function before
's fifth parameter type, sane for returned functionFP6
- function before
's sixth parameter type, sane for returned functionbefore
- function to apply first, has to return a non-null
result so unpacking the parameters
from the tuple is possible@NotNull default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5,FP6,FP7> Function7<R,FP1,FP2,FP3,FP4,FP5,FP6,FP7> after7(@NotNull Function7<FR,FP1,FP2,FP3,FP4,FP5,FP6,FP7> before)
ITuple2
with matching parametric types
which are applied in their order to this function.FR
- function before
's return type, has to be a 2-tuple with matching typesFP1
- function before
's first parameter type, sane for returned functionFP2
- function before
's second parameter type, sane for returned functionFP3
- function before
's third parameter type, sane for returned functionFP4
- function before
's fourth parameter type, sane for returned functionFP5
- function before
's fifth parameter type, sane for returned functionFP6
- function before
's sixth parameter type, sane for returned functionFP7
- function before
's seventh parameter type, sane for returned functionbefore
- function to apply first, has to return a non-null
result so unpacking the parameters
from the tuple is possible@NotNull default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8> Function8<R,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8> after8(@NotNull Function8<FR,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8> before)
ITuple2
with matching parametric types
which are applied in their order to this function.FR
- function before
's return type, has to be a 2-tuple with matching typesFP1
- function before
's first parameter type, sane for returned functionFP2
- function before
's second parameter type, sane for returned functionFP3
- function before
's third parameter type, sane for returned functionFP4
- function before
's fourth parameter type, sane for returned functionFP5
- function before
's fifth parameter type, sane for returned functionFP6
- function before
's sixth parameter type, sane for returned functionFP7
- function before
's seventh parameter type, sane for returned functionFP8
- function before
's seventh parameter type, sane for returned functionbefore
- function to apply first, has to return a non-null
result so unpacking the parameters
from the tuple is possible@NotNull default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8,FP9> Function9<R,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8,FP9> after9(@NotNull Function9<FR,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8,FP9> before)
ITuple2
with matching parametric types
which are applied in their order to this function.FR
- function before
's return type, has to be a 2-tuple with matching typesFP1
- function before
's first parameter type, sane for returned functionFP2
- function before
's second parameter type, sane for returned functionFP3
- function before
's third parameter type, sane for returned functionFP4
- function before
's fourth parameter type, sane for returned functionFP5
- function before
's fifth parameter type, sane for returned functionFP6
- function before
's sixth parameter type, sane for returned functionFP7
- function before
's seventh parameter type, sane for returned functionFP8
- function before
's seventh parameter type, sane for returned functionFP9
- function before
's ninth parameter type, sane for returned functionbefore
- function to apply first, has to return a non-null
result so unpacking the parameters
from the tuple is possible@NotNull static <RR,PP1,PP2> Function2<RR,PP1,PP2> from(@NotNull java.util.function.BiFunction<PP1,PP2,RR> bifunc)
BiFunction
usable as a Function2
.
This is eg useful if you want to make use of partial evaluation.RR
- result typePP1
- first parameter typePP2
- second parameter typebifunc
- bifunctionFunction2
view of the given bifunction@NotNull static <E extends java.lang.Exception,RR,PP1,PP2> Function2<RR,PP1,PP2> nonFragile(@NotNull FragileFunction2<? extends RR,E,? super PP1,? super PP2> fragileFunction)
WrappedFragileException
for any
checked exception thrown during BiFunction.apply(Object, Object)
.E
- exception typeRR
- result type of incoming and outgoing function.PP1
- type of first parameter of returned functionsPP2
- type of second parameter of returned functionsfragileFunction
- function throwing a checked exception@NotNull static <E extends java.lang.Exception,RR,PP1,PP2> Function2<RR,PP1,PP2> nonFragile(@NotNull FragileFunction2<? extends RR,E,? super PP1,? super PP2> fragileFunction, RR fallback)
E
- exception typeRR
- result type of incoming and outgoing function.PP1
- type of first parameter of returned functionsPP2
- type of second parameter of returned functionsfragileFunction
- function throwing a checked exceptionfallback
- fallback returned when fragileFunction
has thrown an exception@NotNull static <E extends java.lang.Exception,RR,PP1,PP2> Function2<RR,PP1,PP2> nonFragileX(@NotNull FragileFunction2<? extends RR,E,? super PP1,? super PP2> fragileFunction, @NotNull Function3<? extends RR,? super E,? super PP1,? super PP2> exceptionHandler)
Function1.nonFragile(FragileFunction1)
)Function1.nonFragile(FragileFunction1, Object)
)E
- exception typeRR
- result type of incoming and outgoing function.PP1
- type of first parameter of returned functionsPP2
- type of second parameter of returned functionsfragileFunction
- function throwing a checked exceptionexceptionHandler
- exception handler. Its return value will be used as return value of the returned function.