Class InvariantEvaluator

java.lang.Object
com.tnsai.invariants.InvariantEvaluator

public class InvariantEvaluator extends Object
Evaluates InvariantExpression against a target object.

Uses reflection to access fields and invoke methods. Supports enum comparisons, null checks, and numeric comparisons.

Author:
TnsAI Team
  • Constructor Details

    • InvariantEvaluator

      public InvariantEvaluator(Object target)
      Creates an evaluator for the given target object.
      Parameters:
      target - the object to evaluate against
  • Method Details

    • evaluate

      public Object evaluate(InvariantExpression expr)
      Evaluates the expression and returns the result.
      Parameters:
      expr - the expression to evaluate
      Returns:
      the evaluation result
    • evaluateAsBoolean

      public boolean evaluateAsBoolean(InvariantExpression expr)
      Evaluates the expression as a boolean.
      Parameters:
      expr - the expression to evaluate
      Returns:
      true if the expression evaluates to true