|
GridGain 3.6.0e
Enterprise Edition |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.gridgain.grid.lang.GridMetadataAwareAdapter
org.gridgain.grid.lang.GridLambdaAdapter
org.gridgain.grid.lang.GridPredicate2<T1,T2>
org.gridgain.grid.lang.GridJexlPredicate2<T1,T2>
T1 - Type of the first free variable, i.e. the element the closure is called on.T2 - Type of the second free variable, i.e. the element the closure is called on.public class GridJexlPredicate2<T1,T2>
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);
...
| Wiki | |
| Forum |
GridFunc.x2(String),
GridFunc.x2(String, String, String),
Serialized Form
![]() |
![]() |
| Constructor Summary | |
|---|---|
GridJexlPredicate2()
Creates JEXL predicate with no expression, variable binding or additional context. |
|
GridJexlPredicate2(String exprStr)
Creates JEXL predicate with given parameters. |
|
GridJexlPredicate2(String exprStr,
String var1)
Creates JEXL predicate with given parameters. |
|
GridJexlPredicate2(String exprStr,
String var1,
String var2)
Creates JEXL predicate with given parameters. |
|
| Method Summary | |
|---|---|
boolean |
apply(T1 t1,
T2 t2)
Predicate body. |
String |
toString()
|
GridJexlPredicate2<T1,T2> |
with(GridTuple2<String,Object>... vals)
Sets JEXL context variables' values and returns this. |
GridJexlPredicate2<T1,T2> |
with(String var,
Object val)
Sets JEXL context variable value and returns this. |
| Methods inherited from class org.gridgain.grid.lang.GridPredicate2 |
|---|
andThen, andThen, andThen, curry, curry, uncurry3 |
| 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, 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 |
|---|
public GridJexlPredicate2()
false.
public GridJexlPredicate2(String exprStr,
String var1)
elem2.
exprStr - JEXL boolean expression. Note that non-boolean return value will evaluate this
predicate to false.var1 - Name of the 1st bound variable in JEXL expression.
public GridJexlPredicate2(String exprStr,
String var1,
String var2)
exprStr - JEXL boolean expression. Note that non-boolean return value will evaluate this
predicate to false.var1 - Name of the 1st bound variable in JEXL expression.var2 - Name of the 2nd bound variable in JEXL expression.public GridJexlPredicate2(String exprStr)
elem.
exprStr - JEXL boolean expression. Note that non-boolean return value will evaluate this
predicate to false.| Method Detail |
|---|
public GridJexlPredicate2<T1,T2> 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 GridJexlPredicate2<T1,T2> 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
T1 t1,
@Nullable
T2 t2)
apply in class GridPredicate2<T1,T2>t1 - First bound free variable, i.e. the element the closure is called or closed on.t2 - Second bound free variable, i.e. the element the closure is called or closed on.
public String toString()
toString in class Object
|
GridGain 3.6.0e
Enterprise Edition |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
|
GridGain - Real Time Big Data
|
|
|