java.lang.Object
io.confluent.kafka.schemaregistry.rules.cel.builtin.BuiltinLibrary
All Implemented Interfaces:
dev.cel.checker.CelCheckerLibrary, dev.cel.compiler.CelCompilerLibrary, dev.cel.parser.CelParserLibrary, dev.cel.runtime.CelInternalRuntimeLibrary, dev.cel.runtime.CelRuntimeLibrary

public class BuiltinLibrary extends Object implements dev.cel.compiler.CelCompilerLibrary, dev.cel.runtime.CelRuntimeLibrary, dev.cel.runtime.CelInternalRuntimeLibrary
Schema Registry's built-in CEL function library. Implements both 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static 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.
    void
    setCheckerOptions(dev.cel.checker.CelCheckerBuilder checkerBuilder)
     
    void
    setRuntimeOptions(dev.cel.runtime.CelRuntimeBuilder runtimeBuilder)
    Plain-CelRuntimeLibrary entry point.
    void
    setRuntimeOptions(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, wait

    Methods 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:
      setCheckerOptions in interface dev.cel.checker.CelCheckerLibrary
    • setRuntimeOptions

      public void setRuntimeOptions(dev.cel.runtime.CelRuntimeBuilder runtimeBuilder)
      Plain-CelRuntimeLibrary entry point. Reached only if a runtime implementation does not recognize CelInternalRuntimeLibrary; it registers the namespaced bindings and skips the standard-function overrides, which have no RuntimeEquality to bind against here.
      Specified by:
      setRuntimeOptions in interface dev.cel.runtime.CelRuntimeLibrary
    • setRuntimeOptions

      public void setRuntimeOptions(dev.cel.runtime.CelRuntimeBuilder runtimeBuilder, dev.cel.runtime.RuntimeEquality runtimeEquality, dev.cel.common.CelOptions celOptions)
      Specified by:
      setRuntimeOptions in interface dev.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 a setStandardFunctions call, 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.