Package com.libdbm.cel
Class Program
java.lang.Object
com.libdbm.cel.Program
A compiled CEL program that can be evaluated multiple times.
A Program represents a parsed CEL expression that can be efficiently evaluated with
different sets of variables. This is more efficient than parsing the expression each time it
needs to be evaluated.
Programs are created using CEL.compile(java.lang.String, com.libdbm.cel.Functions) and should be reused when the same expression
needs to be evaluated multiple times.
-
Method Summary
-
Method Details
-
evaluate
Evaluates the compiled program with the given variables.- Parameters:
variables- A map of variable names to their values- Returns:
- The result of evaluating the expression
- Throws:
com.libdbm.cel.EvaluationError- if an error occurs during evaluation, such as undefined variables or type mismatchesExample:
final Object result = program.evaluate(Map.of( "x", 10, "y", 20, "items", List.of(1, 2, 3) ));
-