Package org.eclipse.xtext.xbase.lib
Class FunctionExtensions
- java.lang.Object
-
- org.eclipse.xtext.xbase.lib.FunctionExtensions
-
-
Constructor Summary
Constructors Constructor Description FunctionExtensions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <V,T,R>
Functions.Function1<V,R>andThen(Functions.Function1<? super V,? extends T> before, Functions.Function1<? super T,? extends R> after)
Returns a composed function that first applies thebefore
function to its input, and then applies theafter
function to the result.static <V1,V2,T,R>
Functions.Function2<V1,V2,R>andThen(Functions.Function2<? super V1,? super V2,? extends T> before, Functions.Function1<? super T,? extends R> after)
Returns a composed function that first applies thebefore
function to its input, and then applies theafter
function to the result.static Procedures.Procedure0
andThen(Procedures.Procedure0 before, Procedures.Procedure0 after)
Returns a composedProcedure1
that performs, in sequence, thebefore
operation followed by theafter
operation.static <T> Procedures.Procedure1<T>
andThen(Procedures.Procedure1<? super T> before, Procedures.Procedure1<? super T> after)
Returns a composedProcedure1
that performs, in sequence, thebefore
operation followed by theafter
operation.static <V,T,R>
Functions.Function1<V,R>compose(Functions.Function1<? super T,? extends R> after, Functions.Function1<? super V,? extends T> before)
Returns a composed function that first applies thebefore
function to its input, and then applies theafter
function to the result.static <P1,RESULT>
Functions.Function0<RESULT>curry(Functions.Function1<? super P1,? extends RESULT> function, P1 argument)
Curries a function that takes one argument.static <P1,P2,RESULT>
Functions.Function1<P2,RESULT>curry(Functions.Function2<? super P1,? super P2,? extends RESULT> function, P1 argument)
Curries a function that takes two arguments.static <P1,P2,P3,RESULT>
Functions.Function2<P2,P3,RESULT>curry(Functions.Function3<? super P1,? super P2,? super P3,? extends RESULT> function, P1 argument)
Curries a function that takes three arguments.static <P1,P2,P3,P4,RESULT>
Functions.Function3<P2,P3,P4,RESULT>curry(Functions.Function4<? super P1,? super P2,? super P3,? super P4,? extends RESULT> function, P1 argument)
Curries a function that takes four arguments.static <P1,P2,P3,P4,P5,RESULT>
Functions.Function4<P2,P3,P4,P5,RESULT>curry(Functions.Function5<? super P1,? super P2,? super P3,? super P4,? super P5,? extends RESULT> function, P1 argument)
Curries a function that takes five arguments.static <P1,P2,P3,P4,P5,P6,RESULT>
Functions.Function5<P2,P3,P4,P5,P6,RESULT>curry(Functions.Function6<? super P1,? super P2,? super P3,? super P4,? super P5,? super P6,? extends RESULT> function, P1 argument)
Curries a function that takes six arguments.
-
-
-
Method Detail
-
curry
@Pure public static <P1,RESULT> Functions.Function0<RESULT> curry(Functions.Function1<? super P1,? extends RESULT> function, P1 argument)
Curries a function that takes one argument.- Parameters:
function
- the original function. May not benull
.argument
- the fixed argument.- Returns:
- a function that takes no arguments. Never
null
.
-
curry
@Pure public static <P1,P2,RESULT> Functions.Function1<P2,RESULT> curry(Functions.Function2<? super P1,? super P2,? extends RESULT> function, P1 argument)
Curries a function that takes two arguments.- Parameters:
function
- the original function. May not benull
.argument
- the fixed first argument offunction
.- Returns:
- a function that takes one argument. Never
null
.
-
curry
@Pure public static <P1,P2,P3,RESULT> Functions.Function2<P2,P3,RESULT> curry(Functions.Function3<? super P1,? super P2,? super P3,? extends RESULT> function, P1 argument)
Curries a function that takes three arguments.- Parameters:
function
- the original function. May not benull
.argument
- the fixed first argument offunction
.- Returns:
- a function that takes two arguments. Never
null
.
-
curry
@Pure public static <P1,P2,P3,P4,RESULT> Functions.Function3<P2,P3,P4,RESULT> curry(Functions.Function4<? super P1,? super P2,? super P3,? super P4,? extends RESULT> function, P1 argument)
Curries a function that takes four arguments.- Parameters:
function
- the original function. May not benull
.argument
- the fixed first argument offunction
.- Returns:
- a function that takes three arguments. Never
null
.
-
curry
@Pure public static <P1,P2,P3,P4,P5,RESULT> Functions.Function4<P2,P3,P4,P5,RESULT> curry(Functions.Function5<? super P1,? super P2,? super P3,? super P4,? super P5,? extends RESULT> function, P1 argument)
Curries a function that takes five arguments.- Parameters:
function
- the original function. May not benull
.argument
- the fixed first argument offunction
.- Returns:
- a function that takes four arguments. Never
null
.
-
curry
@Pure public static <P1,P2,P3,P4,P5,P6,RESULT> Functions.Function5<P2,P3,P4,P5,P6,RESULT> curry(Functions.Function6<? super P1,? super P2,? super P3,? super P4,? super P5,? super P6,? extends RESULT> function, P1 argument)
Curries a function that takes six arguments.- Parameters:
function
- the original function. May not benull
.argument
- the fixed first argument offunction
.- Returns:
- a function that takes five arguments. Never
null
.
-
compose
public static <V,T,R> Functions.Function1<V,R> compose(Functions.Function1<? super T,? extends R> after, Functions.Function1<? super V,? extends T> before)
Returns a composed function that first applies thebefore
function to its input, and then applies theafter
function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the composed function.- Type Parameters:
V
- the type of input to thebefore
function, and to the composed functionT
- the type of output of thebefore
function, and input to theafter
functionR
- the type of output to theafter
function, and to the composed function- Parameters:
after
- the function to apply after the before function is appliedbefore
- the function to apply before the after function is applied- Returns:
- a composed function that first applies the
before
function and then applies theafter
function - Throws:
java.lang.NullPointerException
- ifbefore
orafter
isnull
- Since:
- 2.9
- See Also:
andThen(Functions.Function1, Functions.Function1)
-
andThen
public static <V,T,R> Functions.Function1<V,R> andThen(Functions.Function1<? super V,? extends T> before, Functions.Function1<? super T,? extends R> after)
Returns a composed function that first applies thebefore
function to its input, and then applies theafter
function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the composed function.- Type Parameters:
V
- the type of input to thebefore
function, and to the composed functionT
- the type of output of thebefore
function, and input to theafter
functionR
- the type of output to theafter
function, and to the composed function- Parameters:
before
- the function to apply before the after function is appliedafter
- the function to apply after the before function is applied- Returns:
- a composed function that first applies the
before
function and then applies theafter
function - Throws:
java.lang.NullPointerException
- ifbefore
orafter
isnull
- Since:
- 2.9
- See Also:
compose(Functions.Function1, Functions.Function1)
-
andThen
public static <V1,V2,T,R> Functions.Function2<V1,V2,R> andThen(Functions.Function2<? super V1,? super V2,? extends T> before, Functions.Function1<? super T,? extends R> after)
Returns a composed function that first applies thebefore
function to its input, and then applies theafter
function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the composed function.- Type Parameters:
V1
- the type of the first parameter to thebefore
function, and to the composed functionV2
- the type of the second parameter to thebefore
function, and to the composed functionT
- the type of output of thebefore
function, and input to theafter
functionR
- the type of output to theafter
function, and to the composed function- Parameters:
before
- the function to apply before theafter
function is appliedafter
- the function to apply after thebefore
function is applied- Returns:
- a composed function that first applies the
before
function and then applies theafter
function - Throws:
java.lang.NullPointerException
- ifbefore
orafter
is null- Since:
- 2.9
- See Also:
compose(Functions.Function1, Functions.Function1)
-
andThen
public static <T> Procedures.Procedure1<T> andThen(Procedures.Procedure1<? super T> before, Procedures.Procedure1<? super T> after)
Returns a composedProcedure1
that performs, in sequence, thebefore
operation followed by theafter
operation. If performing either operation throws an exception, it is relayed to the caller of the composed operation. If performing thebefore
operation throws an exception, theafter
operation will not be performed.- Type Parameters:
T
- the type of input for thebefore
operation- Parameters:
before
- the operation to perform firstafter
- the operation to perform afterwards- Returns:
- a composed
Procedure1
that performs in sequence thebefore
operation followed by theafter
operation - Throws:
java.lang.NullPointerException
- ifbefore
orafter
is null- Since:
- 2.9
-
andThen
public static Procedures.Procedure0 andThen(Procedures.Procedure0 before, Procedures.Procedure0 after)
Returns a composedProcedure1
that performs, in sequence, thebefore
operation followed by theafter
operation. If performing either operation throws an exception, it is relayed to the caller of the composed operation. If performing thebefore
operation throws an exception, theafter
operation will not be performed.- Parameters:
before
- the operation to perform firstafter
- the operation to perform afterwards- Returns:
- a composed
Procedure1
that performs in sequence thebefore
operation followed by theafter
operation - Throws:
java.lang.NullPointerException
- ifbefore
orafter
is null- Since:
- 2.9
-
-