2020import dev .cel .compiler .CelCompilerImpl ;
2121import dev .cel .parser .CelParserImpl ;
2222import dev .cel .runtime .CelRuntime ;
23+ import dev .cel .runtime .CelRuntimeImpl ;
2324import dev .cel .runtime .CelRuntimeLegacyImpl ;
2425
2526/** Helper class to configure the entire CEL stack in a common interface. */
@@ -44,6 +45,30 @@ public static CelBuilder standardCelBuilder() {
4445 .setStandardEnvironmentEnabled (true );
4546 }
4647
48+ /**
49+ * Creates a builder for configuring CEL for the parsing, optional type-checking, and evaluation
50+ * of expressions using the Program Planner.
51+ *
52+ * <p>The {@code ProgramPlanner} architecture provides key benefits over the {@link
53+ * #standardCelBuilder()}:
54+ *
55+ * <ul>
56+ * <li><b>Performance:</b> Programs can be cached for improving evaluation speed.
57+ * <li><b>Parsed-only expression evaluation:</b> Unlike the traditional stack which required
58+ * supplying type-checked expressions, this architecture handles both parsed-only and
59+ * type-checked expressions.
60+ * </ul>
61+ */
62+ public static CelBuilder plannerCelBuilder () {
63+ return CelImpl .newBuilder (
64+ CelCompilerImpl .newBuilder (
65+ CelParserImpl .newBuilder (),
66+ CelCheckerLegacyImpl .newBuilder ().setStandardEnvironmentEnabled (true )),
67+ CelRuntimeImpl .newBuilder ())
68+ // CEL-Internal-2
69+ .setOptions (CelOptions .current ().enableHeterogeneousNumericComparisons (true ).build ());
70+ }
71+
4772 /** Combines a prebuilt {@link CelCompiler} and {@link CelRuntime} into {@link Cel}. */
4873 public static Cel combine (CelCompiler celCompiler , CelRuntime celRuntime ) {
4974 return CelImpl .combine (celCompiler , celRuntime );
0 commit comments