Class 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 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  X.And
      "AND" logical operator
      static class  X.BinaryOp
      Abstract binary operators
      static 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 operator
      static class  X.Or
      "OR" logical operator
      static class  X.UnaryOp
      Abstract single-operand operator
      static 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 convenience
      X eq​(X x)
      Convenience method for chain-style notation of expressions.
      static X eq​(X x, X y)
      Static factory method, for convenience
      java.lang.Object eval()
      Convenience version of eval(Map) that is equivalent to calling eval(Map) with an empty map or a null argument.
      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 of eval(Map) accepting a Properties argument
      X 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 convenience
      X not()
      Convenience method for chain-style notation of expressions.
      static X not​(X x)
      Static factory method, for convenience
      X 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​(java.lang.Object val)
      Static factory method, for convenience
      static X var​(java.lang.String name)
      Static factory method, for convenience
      X 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 Detail

      • X

        public X()
    • Method Detail

      • 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​(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 of eval(Map) accepting a Properties argument
      • eval

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