GridGain™ 4.3.1e
Enterprise "Big Data" Edition

org.gridgain.grid.lang
Class GridClosure2<E1,E2,R>

java.lang.Object
  extended by org.gridgain.grid.lang.GridLambdaAdapter
      extended by org.gridgain.grid.lang.GridClosure2<E1,E2,R>
Type Parameters:
E1 - Type of the first free variable, i.e. the element the closure is called or closed on.
E2 - Type of the second free variable, i.e. the element the closure is called or closed on.
R - Type of the closure's return value.
All Implemented Interfaces:
Serializable, GridPeerDeployAware, GridLambda
Direct Known Subclasses:
C2, GridClosure2X

public abstract class GridClosure2<E1,E2,R>
extends GridLambdaAdapter

Defines generic for-each type of closure. Closure is a first-class function that is defined with (or closed over) its free variables that are bound to the closure scope at execution. Since Java 6 doesn't provide a language construct for first-class function the closures are implemented as abstract classes.

Type Alias

To provide for more terse code you can use a typedef C2 class or various factory methods in GridFunc class. Note, however, that since typedefs in Java rely on inheritance you should not use these type aliases in signatures.

Thread Safety

Note that this interface does not impose or assume any specific thread-safety by its implementations. Each implementation can elect what type of thread-safety it provides, if any.

See Also:
C2, GridFunc, Serialized Form
 

Constructor Summary
GridClosure2()
           
 
Method Summary
<A> GridClosure2<E1,E2,A>
andThen(GridClosure<R,A> c)
          Gets closure that applies given closure over the result of this closure.
 GridInClosure2<E1,E2> andThen(GridInClosure<R> c)
          Gets closure that applies given closure over the result of this closure.
abstract  R apply(E1 e1, E2 e2)
          Closure body.
 GridClosure<E2,R> curry(E1 e1)
          Curries this closure with given value.
 GridOutClosure<R> curry(E1 e1, E2 e2)
          Curries this closure with given values.
<E3> GridClosure3<E1,E2,E3,R>
uncurry3()
          Gets closure that ignores its third argument and returns the same value as this closure with first and second arguments.
 
Methods inherited from class org.gridgain.grid.lang.GridLambdaAdapter
classLoader, deployClass, peerDeployLike
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GridClosure2

public GridClosure2()
Method Detail

apply

public abstract R apply(E1 e1,
                        E2 e2)
Closure body.

Parameters:
e1 - First bound free variable, i.e. the element the closure is called or closed on.
e2 - Second bound free variable, i.e. the element the closure is called or closed on.
Returns:
Optional return value.

curry

public GridClosure<E2,R> curry(E1 e1)
Curries this closure with given value. When result closure is called it will be executed with given value.

Parameters:
e1 - Value to curry with.
Returns:
Curried or partially applied closure with given value.

curry

public GridOutClosure<R> curry(E1 e1,
                               E2 e2)
Curries this closure with given values. When result closure is called it will be executed with given values.

Parameters:
e1 - Value to curry with.
e2 - Value to curry with.
Returns:
Curried or partially applied closure with given values.

uncurry3

public <E3> GridClosure3<E1,E2,E3,R> uncurry3()
Gets closure that ignores its third argument and returns the same value as this closure with first and second arguments.

Type Parameters:
E3 - Type of 3d argument that is ignored.
Returns:
Closure that ignores third argument and returns the same value as this closure with first and second arguments.

andThen

public <A> GridClosure2<E1,E2,A> andThen(GridClosure<R,A> c)
Gets closure that applies given closure over the result of this closure.

Type Parameters:
A - Return type of new closure.
Parameters:
c - Closure.
Returns:
New closure.

andThen

public GridInClosure2<E1,E2> andThen(GridInClosure<R> c)
Gets closure that applies given closure over the result of this closure.

Parameters:
c - Closure.
Returns:
New closure.

GridGain™ 4.3.1e
Enterprise "Big Data" Edition

GridGain - In-Memory Big Data
Enterprise "Big Data" Edition, ver. 4.3.1e.10112012
2012 Copyright © GridGain Systems
Follow us:   Follow GridGain on Github Join GridGain User Group Follow GridGain on Twitter Follow GridGain on Vimeo