public final class Functions
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static java.lang.Class<?>[] |
functions |
Constructor and Description |
---|
Functions() |
Modifier and Type | Method and Description |
---|---|
static <R> Function0<R> |
buildInvocation(Function<R> f,
java.util.List<java.lang.Object> args)
Make invocation with
f and args . |
static <R,V> Function0<V> |
compose(Function0<R> first,
Function1<? super R,? extends V> second)
Returns a composed function that first applies
first function to its input, and then
applies the second function to the result. |
static <T,R,V> Function1<T,V> |
compose(Function1<? super T,? extends R> first,
Function1<? super R,? extends V> second)
Returns a composed function that first applies
first function to its input, and then
applies the second function to the result. |
static <T1,T2,R,V> |
compose(Function2<? super T1,? super T2,? extends R> first,
Function1<? super R,? extends V> second)
Returns a composed function that first applies
first function to its input, and then
applies the second function to the result. |
static <T1,T2,T3,R,V> |
compose(Function3<? super T1,? super T2,? super T3,? extends R> first,
Function1<? super R,? extends V> second)
Returns a composed function that first applies
first function to its input, and then
applies the second function to the result. |
static <T1,T2,T3,T4,R,V> |
compose(Function4<? super T1,? super T2,? super T3,? super T4,? extends R> first,
Function1<? super R,? extends V> second)
Returns a composed function that first applies
first function to its input, and then
applies the second function to the result. |
static <T1,T2,T3,T4,T5,R,V> |
compose(Function5<? super T1,? super T2,? super T3,? super T4,? super T5,? extends R> first,
Function1<? super R,? extends V> second)
Returns a composed function that first applies
first function to its input, and then
applies the second function to the result. |
static <R> Function0<R> |
identify(Function0<R> f,
java.lang.String identity)
Identify a function by name.
|
static <T,R> Function1<T,R> |
identify(Function1<T,R> f,
java.lang.String identity)
Identify a function by name.
|
static <T1,T2,R> Function2<T1,T2,R> |
identify(Function2<T1,T2,R> f,
java.lang.String identity)
Identify a function by name.
|
static <T1,T2,T3,R> |
identify(Function3<T1,T2,T3,R> f,
java.lang.String identity)
Identify a function by name.
|
static <T1,T2,T3,T4,R> |
identify(Function4<T1,T2,T3,T4,R> f,
java.lang.String identity)
Identify a function by name.
|
static <T1,T2,T3,T4,T5,R> |
identify(Function5<T1,T2,T3,T4,T5,R> f,
java.lang.String identity)
Identify a function by name.
|
static <R> R |
invoke(Function<R> f,
java.util.List<java.lang.Object> args)
Invoke target
f with args and return result. |
public static <R> R invoke(Function<R> f, java.util.List<java.lang.Object> args)
f
with args
and return result.R
- an invocation return typef
- a function to invokeargs
- arguments to passpublic static <R> Function0<R> buildInvocation(Function<R> f, java.util.List<java.lang.Object> args)
f
and args
.R
- an invocation return typef
- a function to invokeargs
- arguments to passpublic static <R> Function0<R> identify(Function0<R> f, java.lang.String identity)
R
- a function return typef
- a function to identifyidentity
- an identitypublic static <T,R> Function1<T,R> identify(Function1<T,R> f, java.lang.String identity)
T
- a function argument typeR
- a function return typef
- a function to identifyidentity
- an identitypublic static <T1,T2,R> Function2<T1,T2,R> identify(Function2<T1,T2,R> f, java.lang.String identity)
T1
- a function 1st argument typeT2
- a function 2nd argument typeR
- a function return typef
- a function to identifyidentity
- an identitypublic static <T1,T2,T3,R> Function3<T1,T2,T3,R> identify(Function3<T1,T2,T3,R> f, java.lang.String identity)
T1
- a function 1st argument typeT2
- a function 2nd argument typeT3
- a function 3rd argument typeR
- a function return typef
- a function to identifyidentity
- an identitypublic static <T1,T2,T3,T4,R> Function4<T1,T2,T3,T4,R> identify(Function4<T1,T2,T3,T4,R> f, java.lang.String identity)
T1
- a function 1st argument typeT2
- a function 2nd argument typeT3
- a function 3rd argument typeT4
- a function 4th argument typeR
- a function return typef
- a function to identifyidentity
- an identitypublic static <T1,T2,T3,T4,T5,R> Function5<T1,T2,T3,T4,T5,R> identify(Function5<T1,T2,T3,T4,T5,R> f, java.lang.String identity)
T1
- a function 1st argument typeT2
- a function 2nd argument typeT3
- a function 3rd argument typeT4
- a function 4th argument typeT5
- a function 5th argument typeR
- a function return typef
- a function to identifyidentity
- an identitypublic static <R,V> Function0<V> compose(Function0<R> first, Function1<? super R,? extends V> second)
first
function to its input, and then
applies the second
function to the result.R
- the output type of first
and the input type of second
V
- the type of output of the second
functionfirst
- the function to invoke firstsecond
- the function to invoke secondfirst
function and then applies the
second
functionjava.lang.NullPointerException
- if before or after is nullpublic static <T,R,V> Function1<T,V> compose(Function1<? super T,? extends R> first, Function1<? super R,? extends V> second)
first
function to its input, and then
applies the second
function to the result.T
- the input type of first
R
- the output type of first
and the input type of second
V
- the type of output of the second
functionfirst
- the function to invoke firstsecond
- the function to invoke secondfirst
function and then applies the
second
functionjava.lang.NullPointerException
- if before or after is nullpublic static <T1,T2,R,V> Function2<T1,T2,V> compose(Function2<? super T1,? super T2,? extends R> first, Function1<? super R,? extends V> second)
first
function to its input, and then
applies the second
function to the result.T1
- the 1st input type of first
T2
- the 2nd input type of first
R
- the output type of first
and the input type of second
V
- the type of output of the second
functionfirst
- the function to invoke firstsecond
- the function to invoke secondfirst
function and then applies the
second
functionjava.lang.NullPointerException
- if before or after is nullpublic static <T1,T2,T3,R,V> Function3<T1,T2,T3,V> compose(Function3<? super T1,? super T2,? super T3,? extends R> first, Function1<? super R,? extends V> second)
first
function to its input, and then
applies the second
function to the result.T1
- the 1st input type of first
T2
- the 2nd input type of first
T3
- the 3rd input type of first
R
- the output type of first
and the input type of second
V
- the type of output of the second
functionfirst
- the function to invoke firstsecond
- the function to invoke secondfirst
function and then applies the
second
functionjava.lang.NullPointerException
- if before or after is nullpublic static <T1,T2,T3,T4,R,V> Function4<T1,T2,T3,T4,V> compose(Function4<? super T1,? super T2,? super T3,? super T4,? extends R> first, Function1<? super R,? extends V> second)
first
function to its input, and then
applies the second
function to the result.T1
- the 1st input type of first
T2
- the 2nd input type of first
T3
- the 3rd input type of first
T4
- the 3rd input type of first
R
- the output type of first
and the input type of second
V
- the type of output of the second
functionfirst
- the function to invoke firstsecond
- the function to invoke secondfirst
function and then applies the
second
functionjava.lang.NullPointerException
- if before or after is nullpublic static <T1,T2,T3,T4,T5,R,V> Function5<T1,T2,T3,T4,T5,V> compose(Function5<? super T1,? super T2,? super T3,? super T4,? super T5,? extends R> first, Function1<? super R,? extends V> second)
first
function to its input, and then
applies the second
function to the result.T1
- the 1st input type of first
T2
- the 2nd input type of first
T3
- the 3rd input type of first
T4
- the 3rd input type of first
T5
- the 4th input type of first
R
- the output type of first
and the input type of second
V
- the type of output of the second
functionfirst
- the function to invoke firstsecond
- the function to invoke secondfirst
function and then applies the
second
functionjava.lang.NullPointerException
- if before or after is null