GridGain™ 3.6.0e
Enterprise Edition

org.gridgain.grid.lang
Class GridPredicate<E1>

java.lang.Object
  extended by org.gridgain.grid.lang.GridMetadataAwareAdapter
      extended by org.gridgain.grid.lang.GridLambdaAdapter
          extended by org.gridgain.grid.lang.GridPredicate<E1>
Type Parameters:
E1 - Type of the free variable, i.e. the element the predicate is called on.
All Implemented Interfaces:
Serializable, Cloneable, GridMetadataAware, GridPeerDeployAware, GridLambda
Direct Known Subclasses:
GridJexlPredicate, GridNodePredicate, GridPredicateX, P1, PCE, PE, PN

public abstract class GridPredicate<E1>
extends GridLambdaAdapter

Defines predicate construct. Predicate like 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.

Type Alias

To provide for more terse code you can use a typedef P1 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.

Wiki & Forum:


Wiki
Forum

See Also:
P1, GridFunc, Serialized Form
 

Constructor Summary
GridPredicate()
           
 
Method Summary
<A> GridClosure<E1,A>
andThen(GridClosure<Boolean,A> c)
          Gets closure that applies given closure over the result of this predicate.
 GridInClosure<E1> andThen(GridInClosure<Boolean> c)
          Gets closure that applies given closure over the result of this predicate.
 GridPredicate<E1> andThen(GridPredicate<Boolean> c)
          Gets predicate that applies given predicate over the result of this predicate.
abstract  boolean apply(E1 e)
          Predicate body.
<A> GridPredicate<A>
compose(GridClosure<A,E1> c)
          Gets predicate that applies this predicate over the result of given closure.
<A1,A2> GridPredicate2<A1,A2>
compose(GridClosure2<A1,A2,E1> c)
          Gets predicate that applies this predicate over the result of given closure.
<A1,A2,A3> GridPredicate3<A1,A2,A3>
compose(GridClosure3<A1,A2,A3,E1> c)
          Gets predicate that applies this predicate over the result of given closure.
 GridAbsPredicate compose(GridOutClosure<E1> c)
          Gets predicate that applies this predicate over the result of given closure.
 GridAbsPredicate curry(E1 e)
          Curries this predicate with given value.
<E2> GridPredicate2<E1,E2>
uncurry2()
          Gets predicate that ignores its second argument and returns the same value as this predicate with just one first argument.
<E2,E3> GridPredicate3<E1,E2,E3>
uncurry3()
          Gets predicate that ignores its second and third arguments and returns the same value as this predicate with just one first argument.
 
Methods inherited from class org.gridgain.grid.lang.GridLambdaAdapter
classLoader, deployClass, peerDeployLike, withMeta
 
Methods inherited from class org.gridgain.grid.lang.GridMetadataAwareAdapter
addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, clone, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, putMetaIfAbsent, readExternalMeta, removeMeta, removeMeta, replaceMeta, writeExternalMeta
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.gridgain.grid.GridMetadataAware
addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, putMetaIfAbsent, removeMeta, removeMeta, replaceMeta
 

Constructor Detail

GridPredicate

public GridPredicate()
Method Detail

apply

public abstract boolean apply(E1 e)
Predicate body.

Parameters:
e - Bound free variable, i.e. the element the closure is called or closed on.
Returns:
Return value.

curry

public GridAbsPredicate curry(E1 e)
Curries this predicate with given value. When result predicate is called it will be executed with given value.

Parameters:
e - Value to curry with.
Returns:
Curried or partially applied predicate with given value.

uncurry2

public <E2> GridPredicate2<E1,E2> uncurry2()
Gets predicate that ignores its second argument and returns the same value as this predicate with just one first argument.

Type Parameters:
E2 - Type of 2nd argument that is ignored.
Returns:
Predicate that ignores its second argument and returns the same value as this predicate with just one first argument.

uncurry3

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

Type Parameters:
E2 - Type of 2nd argument that is ignored.
E3 - Type of 3d argument that is ignored.
Returns:
Predicate that ignores its second and third arguments and returns the same value as this predicate with just one first argument.

andThen

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

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

andThen

public GridInClosure<E1> andThen(GridInClosure<Boolean> c)
Gets closure that applies given closure over the result of this predicate.

Parameters:
c - Closure.
Returns:
New closure.

andThen

public GridPredicate<E1> andThen(GridPredicate<Boolean> c)
Gets predicate that applies given predicate over the result of this predicate.

Parameters:
c - Predicate.
Returns:
New predicate.

compose

public GridAbsPredicate compose(GridOutClosure<E1> c)
Gets predicate that applies this predicate over the result of given closure.

Parameters:
c - Closure.
Returns:
New predicate.

compose

public <A> GridPredicate<A> compose(GridClosure<A,E1> c)
Gets predicate that applies this predicate over the result of given closure.

Type Parameters:
A - Argument type of new predicate.
Parameters:
c - Closure.
Returns:
New predicate.

compose

public <A1,A2> GridPredicate2<A1,A2> compose(GridClosure2<A1,A2,E1> c)
Gets predicate that applies this predicate over the result of given closure.

Type Parameters:
A1 - First argument type of new predicate.
A2 - Second argument type of new predicate.
Parameters:
c - Closure.
Returns:
New predicate.

compose

public <A1,A2,A3> GridPredicate3<A1,A2,A3> compose(GridClosure3<A1,A2,A3,E1> c)
Gets predicate that applies this predicate over the result of given closure.

Type Parameters:
A1 - First argument type of new predicate.
A2 - Second argument type of new predicate.
A3 - Third argument type of new predicate.
Parameters:
c - Closure.
Returns:
New predicate.

GridGain™ 3.6.0e
Enterprise Edition

GridGain - Real Time Big Data
Enterprise Edition, ver. 3.6.0e.13012012
2012 Copyright © GridGain Systems
Follow us:   Follow GridGain on Github Follow GridGain on Facebook Join GridGain User Group Follow GridGain on Twitter Follow GridGain on YouTube