Interface CelCheckerBuilder

  • All Known Implementing Classes:
    CelCheckerLegacyImpl.Builder

    public interface CelCheckerBuilder
    Interface for building an instance of CelChecker
    • Method Detail

      • setOptions

        @CanIgnoreReturnValue
        CelCheckerBuilder setOptions​(dev.cel.common.CelOptions options)
        Set the CelOptions used to enable fixes and features for this CEL instances.
      • options

        dev.cel.common.CelOptions options()
        Retrieves the currently configured CelOptions in the builder.
      • setContainer

        @CanIgnoreReturnValue
        CelCheckerBuilder setContainer​(dev.cel.common.CelContainer container)
        Set the CelContainer to use as the namespace for resolving CEL expression variables and functions.
      • container

        dev.cel.common.CelContainer container()
        Retrieves the currently configured CelContainer in the builder.
      • addDeclarations

        @CanIgnoreReturnValue
        CelCheckerBuilder addDeclarations​(dev.cel.expr.Decl... declarations)
        Add variable and function declarations to the CEL environment.
      • addDeclarations

        @CanIgnoreReturnValue
        CelCheckerBuilder addDeclarations​(java.lang.Iterable<dev.cel.expr.Decl> declarations)
        Add variable and function declarations to the CEL environment.
      • addFunctionDeclarations

        @CanIgnoreReturnValue
        CelCheckerBuilder addFunctionDeclarations​(CelFunctionDecl... celFunctionDecls)
        Add function declaration CelFunctionDecl to the CEL environment.
      • addFunctionDeclarations

        @CanIgnoreReturnValue
        CelCheckerBuilder addFunctionDeclarations​(java.lang.Iterable<CelFunctionDecl> celFunctionDecls)
        Add function declaration CelFunctionDecl to the CEL environment.
      • addVarDeclarations

        @CanIgnoreReturnValue
        CelCheckerBuilder addVarDeclarations​(CelVarDecl... celVarDecls)
        Add variable declaration CelVarDecl to the CEL environment.
      • addVarDeclarations

        @CanIgnoreReturnValue
        CelCheckerBuilder addVarDeclarations​(java.lang.Iterable<CelVarDecl> celVarDecls)
        Add variable declaration CelVarDecl to the CEL environment.
      • addProtoTypeMasks

        @CanIgnoreReturnValue
        CelCheckerBuilder addProtoTypeMasks​(ProtoTypeMask... typeMasks)
        Add one or more ProtoTypeMask values. The ProtoTypeMask values will be used to compute a set of Decl values using a protobuf message's fields as the names and types of the variables if ProtoTypeMask.fieldsAreVariableDeclarations() is true.

        Note, this feature may not work with custom TypeProvider implementations out of the box, as it requires the implementation of TypeProvider.lookupFieldNames(dev.cel.expr.Type) to return the set of all fields declared on the protobuf type.

      • addProtoTypeMasks

        @CanIgnoreReturnValue
        CelCheckerBuilder addProtoTypeMasks​(java.lang.Iterable<ProtoTypeMask> typeMasks)
        Add one or more ProtoTypeMask values. The ProtoTypeMask values will be used to compute a set of Decl values using a protobuf message's fields as the names and types of the variables if ProtoTypeMask.fieldsAreVariableDeclarations() is true.

        Note, this feature may not work with custom TypeProvider implementations out of the box, as it requires the implementation of TypeProvider.lookupFieldNames(dev.cel.expr.Type) to return the set of all fields declared on the protobuf type.

      • setResultType

        @CanIgnoreReturnValue
        CelCheckerBuilder setResultType​(dev.cel.common.types.CelType resultType)
        Set the expected resultType for the type-checked expression.
      • setProtoResultType

        @CanIgnoreReturnValue
        CelCheckerBuilder setProtoResultType​(dev.cel.expr.Type resultType)
        Set the expected resultType in proto format described in checked.proto for the type-checked expression.
      • setTypeProvider

        @CanIgnoreReturnValue
        CelCheckerBuilder setTypeProvider​(dev.cel.common.types.CelTypeProvider celTypeProvider)
        Set the celTypeProvider for use with type-checking expressions.
      • addMessageTypes

        @CanIgnoreReturnValue
        CelCheckerBuilder addMessageTypes​(com.google.protobuf.Descriptors.Descriptor... descriptors)
        Add message Descriptors.Descriptors to the use for type-checking and object creation at interpretation time.
      • addMessageTypes

        @CanIgnoreReturnValue
        CelCheckerBuilder addMessageTypes​(java.lang.Iterable<com.google.protobuf.Descriptors.Descriptor> descriptors)
        Add message Descriptors.Descriptors to the use for type-checking and object creation at interpretation time.
      • addFileTypes

        @CanIgnoreReturnValue
        CelCheckerBuilder addFileTypes​(com.google.protobuf.Descriptors.FileDescriptor... fileDescriptors)
        Add Descriptors.FileDescriptors to the use for type-checking, and for object creation at interpretation time.
      • addFileTypes

        @CanIgnoreReturnValue
        CelCheckerBuilder addFileTypes​(java.lang.Iterable<com.google.protobuf.Descriptors.FileDescriptor> fileDescriptors)
        Add Descriptors.FileDescriptors to the use for type-checking, and for object creation at interpretation time.
      • addFileTypes

        @CanIgnoreReturnValue
        CelCheckerBuilder addFileTypes​(com.google.protobuf.DescriptorProtos.FileDescriptorSet fileDescriptorSet)
        Add all of the Descriptors.FileDescriptors in a FileDescriptorSet to the use for type-checking, and for object creation at interpretation time.
      • setStandardEnvironmentEnabled

        @CanIgnoreReturnValue
        CelCheckerBuilder setStandardEnvironmentEnabled​(boolean value)
        Enable or disable the standard CEL library functions and variables
      • setStandardDeclarations

        @CanIgnoreReturnValue
        CelCheckerBuilder setStandardDeclarations​(CelStandardDeclarations standardDeclarations)
        Override the standard declarations for the type-checker. This can be used to subset the standard environment to only expose the desired declarations to the type-checker. setStandardEnvironmentEnabled(boolean) must be set to false for this to take effect.
      • addLibraries

        @CanIgnoreReturnValue
        CelCheckerBuilder addLibraries​(java.lang.Iterable<? extends CelCheckerLibrary> libraries)
        Adds a collection of libraries for parsing and type-checking.
      • build

        @CheckReturnValue
        CelChecker build()
        Build a new instance of the CelChecker.