|
GridGain 4.3.1e
Enterprise "Big Data" Edition |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.gridgain.grid.lang.GridLambdaAdapter
org.gridgain.grid.lang.GridPredicate<T>
org.gridgain.grid.lang.GridJexlPredicate<T>
T - Type of the free variable, i.e. the element the closure is called on.public class GridJexlPredicate<T>
Defines a predicate based on Apache JEXL 2.0 boolean expression.
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.
JEXL predicate binds free variables to JEXL context either with default names or with names
supplied by the caller. If bind name is not provided the default name is elemN, where N is
1-based index of the variable. The following code snippet (using GridJexlPredicate2 as an example):
...
// Create new JEXL predicate with default binding names.
new GridJexlPredicate2<String, String>("elem1.length > 0 elem2.length == elem1.length");
...
is identical to this one:
...
// Create new JEXL predicate with custom binding names.
new GridJexlPredicate2<String, String>("s1.length > 0 && s1.length == s2.length", "s1", "s2");
...
Typedefs and factory methods from GridFunc class can be used to shorten the generics code
and provide for convenient and terse code when working with predicates (as well as with closures and tuples):
...
// Similar as above using typedefs and factory methods.
F.x2("s1.length > 0 && s1.length == s2.length", "s1", "s2");
// Additional context.
F.x2("s1.length > n && s1.length == s2.length", "s1", "s2").with("n", 10);
...
GridFunc.x1(String, String),
GridFunc.x1(String),
Serialized Form
![]() |
![]() |
| Constructor Summary | |
|---|---|
GridJexlPredicate()
Creates JEXL predicate with no expression, variable binding or additional context. |
|
GridJexlPredicate(String exprStr)
Creates JEXL predicate with given parameters. |
|
GridJexlPredicate(String exprStr,
String var)
Creates JEXL predicate with given parameters. |
|
| Method Summary | |
|---|---|
boolean |
apply(T t)
Predicate body. |
String |
toString()
|
GridJexlPredicate<T> |
with(GridTuple2<String,Object>... vals)
Sets JEXL context variables' values and returns this. |
GridJexlPredicate<T> |
with(String var,
Object val)
Sets JEXL context variable value and returns this. |
| Methods inherited from class org.gridgain.grid.lang.GridPredicate |
|---|
andThen, andThen, andThen, compose, compose, compose, compose, curry, uncurry2, uncurry3 |
| 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, wait, wait, wait |
| Constructor Detail |
|---|
public GridJexlPredicate()
false.
public GridJexlPredicate(String exprStr,
String var)
exprStr - JEXL boolean expression. Note that non-boolean return value will evaluate this
predicate to false.var - Name of the bound variable in JEXL expression.public GridJexlPredicate(String exprStr)
elem.
exprStr - JEXL boolean expression. Note that non-boolean return value will evaluate this
predicate to false.| Method Detail |
|---|
public GridJexlPredicate<T> with(String var, @Nullable Object val)
this.
var - Name of the variable in JEXL context (new or existing).val - Value to be set or overridden in JEXL context.
public GridJexlPredicate<T> with(GridTuple2<String,Object>... vals)
this.
vals - Set of tuples representing JEXL context to be bound. First element
in the tuple represents the name and the second element represents its value in the context.
public boolean apply(@Nullable
T t)
apply in class GridPredicate<T>t - Bound free variable, i.e. the element the closure is called or closed on.
public String toString()
toString in class Object
|
GridGain 4.3.1e
Enterprise "Big Data" Edition |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
|
GridGain - In-Memory Big Data
|
|
|