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 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 to false while
 var("a").le(val(6)).and(var("b").eq(val("hello"))).eval(m) 
 
would evaluate to true.
Author:
hb
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    "AND" logical operator
    static class 
    Abstract binary operators
    static class 
    "equality" comparison operator.
    static class 
    "greater or equal" comparison operator.
    static class 
    "greater than" comparison operator.
    static class 
    "containment" operator.
    static class 
    "less or equal" comparison operator.
    static class 
    "less than" comparison operator.
    static class 
    "not equals" comparison operator.
    static class 
    Negation logical operator
    static class 
    "OR" logical operator
    static class 
    Abstract single-operand operator
    static class 
    Explicit value.
    static class 
    Variable of field value operator.
    static class 
    "XOR" logical operator
  • Constructor Summary

    Constructors
    Constructor
    Description
    X()
     
  • Method Summary

    Modifier and Type
    Method
    Description
    and(X x)
    Convenience method for chain-style notation of expressions.
    static X
    and(X x, X y)
    Static factory method, for convenience
    eq(X x)
    Convenience method for chain-style notation of expressions.
    static X
    eq(X x, X y)
    Static factory method, for convenience
    Convenience version of eval(Map) that is equivalent to calling eval(Map) with an empty map or a null argument.
    abstract Object
    eval(Map<String,Object> context)
    Evaluation of the expression over a map style context that defines variable values.
    eval(Properties context)
    Convenience version of eval(Map) accepting a Properties argument
    ge(X x)
    Convenience method for chain-style notation of expressions.
    gt(X x)
    Convenience method for chain-style notation of expressions.
    in(X x)
    Convenience method for chain-style notation of expressions.
    le(X x)
    Convenience method for chain-style notation of expressions.
    lt(X x)
    Convenience method for chain-style notation of expressions.
    neq(X x)
    Convenience method for chain-style notation of expressions.
    static X
    neq(X x, X y)
    Static factory method, for convenience
    not()
    Convenience method for chain-style notation of expressions.
    static X
    not(X x)
    Static factory method, for convenience
    or(X x)
    Convenience method for chain-style notation of expressions.
    static X
    or(X x, X y)
    Static factory method, for convenience
    static X
    val(Object val)
    Static factory method, for convenience
    static X
    var(String name)
    Static factory method, for convenience
    xor(X x)
    Convenience method for chain-style notation of expressions.
    static X
    xor(X x, X y)
    Static factory method, for convenience

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • X

      public X()
  • Method Details

    • or

      public X or(X x)
      Convenience method for chain-style notation of expressions.
    • and

      public X and(X x)
      Convenience method for chain-style notation of expressions.
    • xor

      public X xor(X x)
      Convenience method for chain-style notation of expressions.
    • eq

      public X eq(X x)
      Convenience method for chain-style notation of expressions.
    • lt

      public X lt(X x)
      Convenience method for chain-style notation of expressions.
    • le

      public X le(X x)
      Convenience method for chain-style notation of expressions.
    • gt

      public X gt(X x)
      Convenience method for chain-style notation of expressions.
    • ge

      public X ge(X x)
      Convenience method for chain-style notation of expressions.
    • in

      public X in(X x)
      Convenience method for chain-style notation of expressions.
    • neq

      public X neq(X x)
      Convenience method for chain-style notation of expressions.
    • not

      public X not()
      Convenience method for chain-style notation of expressions.
    • or

      public static X or(X x, X y)
      Static factory method, for convenience
    • and

      public static X and(X x, X y)
      Static factory method, for convenience
    • xor

      public static X xor(X x, X y)
      Static factory method, for convenience
    • eq

      public static X eq(X x, X y)
      Static factory method, for convenience
    • neq

      public static X neq(X x, X y)
      Static factory method, for convenience
    • not

      public static X not(X x)
      Static factory method, for convenience
    • val

      public static X val(Object val)
      Static factory method, for convenience
    • var

      public static X var(String name)
      Static factory method, for convenience
    • eval

      public abstract Object eval(Map<String,Object> context)
      Evaluation of the expression over a map style context that defines variable values.
    • eval

      public Object eval(Properties context)
      Convenience version of eval(Map) accepting a Properties argument
    • eval

      public Object eval()
      Convenience version of eval(Map) that is equivalent to calling eval(Map) with an empty map or a null argument.