Class BuiltinLibrary
- All Implemented Interfaces:
dev.cel.checker.CelCheckerLibrary,dev.cel.compiler.CelCompilerLibrary,dev.cel.parser.CelParserLibrary,dev.cel.runtime.CelInternalRuntimeLibrary,dev.cel.runtime.CelRuntimeLibrary
CelCompilerLibrary (so BuiltinDeclarations's function
declarations are added to the type-checker) and CelRuntimeLibrary
(so BuiltinOverload's function bindings are added to the runtime).
Specifically CelInternalRuntimeLibrary rather than plain CelRuntimeLibrary,
because BuiltinOverload.standardOverrides(dev.cel.common.CelOptions, dev.cel.runtime.RuntimeEquality) needs the runtime's own
RuntimeEquality: it re-registers standard function bindings, and its ==
replacement delegates every non-decimal comparison to the standard implementation. Building one
by hand is not an option — RuntimeEquality.create(RuntimeHelpers.create(), options)
yields an instance whose adaptProtoToValue throws "Not implemented yet", so it fails on
any comparison involving a protobuf message. The runtime constructs a
ProtoMessageRuntimeEquality and hands it to internal libraries; receiving that is both correct
and less machinery than replicating it.
CelInternalRuntimeLibrary and RuntimeEquality are cel-java @Internal
types — the only two this repository depends on. CelStandardEqualityTest is the pin: its
protoMessageEquality case fails outright if this hook stops supplying a message-capable
equality, so a cel-java upgrade that changes it breaks the build here rather than silently
downstream.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.common.collect.ImmutableSet<dev.cel.runtime.CelStandardFunctions.StandardFunction>The standard functions this library takes over, which the caller must exclude from the runtime's standard functions.voidsetCheckerOptions(dev.cel.checker.CelCheckerBuilder checkerBuilder) voidsetRuntimeOptions(dev.cel.runtime.CelRuntimeBuilder runtimeBuilder) Plain-CelRuntimeLibraryentry point.voidsetRuntimeOptions(dev.cel.runtime.CelRuntimeBuilder runtimeBuilder, dev.cel.runtime.RuntimeEquality runtimeEquality, dev.cel.common.CelOptions celOptions) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.cel.parser.CelParserLibrary
setParserOptions
-
Constructor Details
-
BuiltinLibrary
public BuiltinLibrary()
-
-
Method Details
-
setCheckerOptions
public void setCheckerOptions(dev.cel.checker.CelCheckerBuilder checkerBuilder) - Specified by:
setCheckerOptionsin interfacedev.cel.checker.CelCheckerLibrary
-
setRuntimeOptions
public void setRuntimeOptions(dev.cel.runtime.CelRuntimeBuilder runtimeBuilder) Plain-CelRuntimeLibraryentry point. Reached only if a runtime implementation does not recognizeCelInternalRuntimeLibrary; it registers the namespaced bindings and skips the standard-function overrides, which have noRuntimeEqualityto bind against here.- Specified by:
setRuntimeOptionsin interfacedev.cel.runtime.CelRuntimeLibrary
-
setRuntimeOptions
public void setRuntimeOptions(dev.cel.runtime.CelRuntimeBuilder runtimeBuilder, dev.cel.runtime.RuntimeEquality runtimeEquality, dev.cel.common.CelOptions celOptions) - Specified by:
setRuntimeOptionsin interfacedev.cel.runtime.CelInternalRuntimeLibrary
-
overriddenStandardFunctions
public static com.google.common.collect.ImmutableSet<dev.cel.runtime.CelStandardFunctions.StandardFunction> overriddenStandardFunctions()The standard functions this library takes over, which the caller must exclude from the runtime's standard functions. The exclusion cannot happen here: it is asetStandardFunctionscall, and a second such call silently discards the first, so it has to be made in the same place as any other standard-function subsetting.
-