Package com.zfabrik.util.expression
Class X
- java.lang.Object
-
- com.zfabrik.util.expression.X
-
- Direct Known Subclasses:
X.BinaryOp
,X.UnaryOp
,X.Val
,X.Var
public abstract class X extends java.lang.Object
Simple boolean expression language as a Java expressed DSL.X
is used in component repositories to formulate component queries but may be used anywhere where simple boolean expressions are useful.A built-in evaluation of an expression over a map defining a context is supported.
For example, given a map
m={"a":5, "b":"hello"}
,var("a").ge(val(6)).and(var("b").eq(val("hello"))).eval(m)
would evaluate tofalse
whilevar("a").le(val(6)).and(var("b").eq(val("hello"))).eval(m)
would evaluate totrue
.- Author:
- hb
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
X.And
"AND" logical operatorstatic class
X.BinaryOp
Abstract binary operatorsstatic class
X.Eq
"equality" comparison operator.static class
X.Ge
"greater or equal" comparison operator.static class
X.Gt
"greater than" comparison operator.static class
X.In
"containment" operator.static class
X.Le
"less or equal" comparison operator.static class
X.Lt
"less than" comparison operator.static class
X.Neq
"not equals" comparison operator.static class
X.Not
Negation logical operatorstatic class
X.Or
"OR" logical operatorstatic class
X.UnaryOp
Abstract single-operand operatorstatic class
X.Val
Explicit value.static class
X.Var
Variable of field value operator.static class
X.Xor
"XOR" logical operator
-
Constructor Summary
Constructors Constructor Description X()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description X
and(X x)
Convenience method for chain-style notation of expressions.static X
and(X x, X y)
Static factory method, for convenienceX
eq(X x)
Convenience method for chain-style notation of expressions.static X
eq(X x, X y)
Static factory method, for conveniencejava.lang.Object
eval()
abstract java.lang.Object
eval(java.util.Map<java.lang.String,java.lang.Object> context)
Evaluation of the expression over a map style context that defines variable values.java.lang.Object
eval(java.util.Properties context)
Convenience version ofeval(Map)
accepting aProperties
argumentX
ge(X x)
Convenience method for chain-style notation of expressions.X
gt(X x)
Convenience method for chain-style notation of expressions.X
in(X x)
Convenience method for chain-style notation of expressions.X
le(X x)
Convenience method for chain-style notation of expressions.X
lt(X x)
Convenience method for chain-style notation of expressions.X
neq(X x)
Convenience method for chain-style notation of expressions.static X
neq(X x, X y)
Static factory method, for convenienceX
not()
Convenience method for chain-style notation of expressions.static X
not(X x)
Static factory method, for convenienceX
or(X x)
Convenience method for chain-style notation of expressions.static X
or(X x, X y)
Static factory method, for conveniencestatic X
val(java.lang.Object val)
Static factory method, for conveniencestatic X
var(java.lang.String name)
Static factory method, for convenienceX
xor(X x)
Convenience method for chain-style notation of expressions.static X
xor(X x, X y)
Static factory method, for convenience
-
-
-
Method Detail
-
not
public X not()
Convenience method for chain-style notation of expressions.
-
val
public static X val(java.lang.Object val)
Static factory method, for convenience
-
var
public static X var(java.lang.String name)
Static factory method, for convenience
-
eval
public abstract java.lang.Object eval(java.util.Map<java.lang.String,java.lang.Object> context)
Evaluation of the expression over a map style context that defines variable values.
-
eval
public java.lang.Object eval(java.util.Properties context)
Convenience version ofeval(Map)
accepting aProperties
argument
-
eval
public java.lang.Object eval()
-
-