Package com.tnsai.invariants
Class InvariantEvaluator
java.lang.Object
com.tnsai.invariants.InvariantEvaluator
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classException thrown when evaluation fails. -
Constructor Summary
ConstructorsConstructorDescriptionInvariantEvaluator(Object target) Creates an evaluator for the given target object. -
Method Summary
Modifier and TypeMethodDescriptionevaluate(InvariantExpression expr) Evaluates the expression and returns the result.booleanEvaluates the expression as a boolean.
-
Constructor Details
-
InvariantEvaluator
Creates an evaluator for the given target object.- Parameters:
target- the object to evaluate against
-
-
Method Details
-
evaluate
Evaluates the expression and returns the result.- Parameters:
expr- the expression to evaluate- Returns:
- the evaluation result
-
evaluateAsBoolean
Evaluates the expression as a boolean.- Parameters:
expr- the expression to evaluate- Returns:
- true if the expression evaluates to true
-