org.eclipse.xtext.xbase.lib
Class FunctionExtensions

java.lang.Object
  extended by org.eclipse.xtext.xbase.lib.FunctionExtensions

public class FunctionExtensions
extends java.lang.Object

This is an extension library for functions, e.g. closures.

Author:
Sven Efftinge - Initial contribution and API
See Also:
Functions

Constructor Summary
FunctionExtensions()
           
 
Method Summary
static
<P1,RESULT>
Functions.Function0<RESULT>
curry(Functions.Function1<P1,RESULT> function, P1 argument)
          Curries a function that takes one argument.
static
<P1,P2,RESULT>
Functions.Function1<P2,RESULT>
curry(Functions.Function2<P1,P2,RESULT> function, P1 argument)
          Curries a function that takes two arguments.
static
<P1,P2,P3,RESULT>
Functions.Function2<P2,P3,RESULT>
curry(Functions.Function3<P1,P2,P3,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<P1,P2,P3,P4,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<P1,P2,P3,P4,P5,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<P1,P2,P3,P4,P5,P6,RESULT> function, P1 argument)
          Curries a function that takes six arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FunctionExtensions

public FunctionExtensions()
Method Detail

curry

public static <P1,RESULT> Functions.Function0<RESULT> curry(Functions.Function1<P1,RESULT> function,
                                                            P1 argument)
Curries a function that takes one argument.

Parameters:
function - the original function. May not be null.
argument - the fixed argument.
Returns:
a function that takes no arguments. Never null.

curry

public static <P1,P2,RESULT> Functions.Function1<P2,RESULT> curry(Functions.Function2<P1,P2,RESULT> function,
                                                                  P1 argument)
Curries a function that takes two arguments.

Parameters:
function - the original function. May not be null.
argument - the fixed first argument of function.
Returns:
a function that takes one argument. Never null.

curry

public static <P1,P2,P3,RESULT> Functions.Function2<P2,P3,RESULT> curry(Functions.Function3<P1,P2,P3,RESULT> function,
                                                                        P1 argument)
Curries a function that takes three arguments.

Parameters:
function - the original function. May not be null.
argument - the fixed first argument of function.
Returns:
a function that takes two arguments. Never null.

curry

public static <P1,P2,P3,P4,RESULT> Functions.Function3<P2,P3,P4,RESULT> curry(Functions.Function4<P1,P2,P3,P4,RESULT> function,
                                                                              P1 argument)
Curries a function that takes four arguments.

Parameters:
function - the original function. May not be null.
argument - the fixed first argument of function.
Returns:
a function that takes three arguments. Never null.

curry

public static <P1,P2,P3,P4,P5,RESULT> Functions.Function4<P2,P3,P4,P5,RESULT> curry(Functions.Function5<P1,P2,P3,P4,P5,RESULT> function,
                                                                                    P1 argument)
Curries a function that takes five arguments.

Parameters:
function - the original function. May not be null.
argument - the fixed first argument of function.
Returns:
a function that takes four arguments. Never null.

curry

public static <P1,P2,P3,P4,P5,P6,RESULT> Functions.Function5<P2,P3,P4,P5,P6,RESULT> curry(Functions.Function6<P1,P2,P3,P4,P5,P6,RESULT> function,
                                                                                          P1 argument)
Curries a function that takes six arguments.

Parameters:
function - the original function. May not be null.
argument - the fixed first argument of function.
Returns:
a function that takes five arguments. Never null.