Class ExpressionPropertyCondition

All Implemented Interfaces:
PropertyCondition, Condition, ContextAware, LifeCycle

This class evaluates boolean expressions based on property lookups.

It supports logical operators (NOT, AND, OR) and functions like isNull, isDefined, propertyEquals, and propertyContains. Expressions are parsed using the Shunting-Yard algorithm into Reverse Polish Notation (RPN) for evaluation.

Example expression: isDefined("key1") && propertyEquals("key2", "value")

Properties are resolved via PropertyConditionBase.property(String).

Since:
1.5.24
  • Field Details

    • functionMap

      A map that associates a string key with a function for evaluating boolean conditions.

      This map defines the known functions. It can be overridden by subclasses to define new functions.

      In the context of this class, a function is a function that takes a String argument and returns a boolean.

    • biFunctionMap

      A map that associates a string key with a bi-function for evaluating boolean conditions.

      This map defines the known bi-functions. It can be overridden by subclasses to define new bi-functions.

      In the context of this class, a bi-function is a function that takes two String arguments and returns a boolean.

  • Constructor Details

    • ExpressionPropertyCondition

      Constructs an ExpressionPropertyCondition and initializes the function maps with supported unary and binary functions.
  • Method Details

    • start

      public void start()
      Starts the condition by parsing the expression into tokens and converting them to Reverse Polish Notation (RPN) for evaluation.

      In case of malformed expression, the instance will not enter the "started" state.

      Specified by:
      start in interface LifeCycle
      Overrides:
      start in class PropertyConditionBase
    • getExpression

      Returns the current expression string.
      Returns:
      the expression, or null if not set
    • setExpression

      public void setExpression(String expression)
      Sets the expression to be evaluated.
      Parameters:
      expression - the boolean expression string
    • evaluate

      public boolean evaluate()
      Evaluates the parsed expression against the current property context.

      If the instance is not in started state, returns false.

      Returns:
      true if the expression evaluates to true, false otherwise