Interface CelCompilerBuilder

  • All Known Implementing Classes:
    CelCompilerImpl.Builder

    public interface CelCompilerBuilder
    Interface for building an instance of CelCompiler
    • Method Detail

      • setStandardMacros

        @CanIgnoreReturnValue
        CelCompilerBuilder setStandardMacros​(CelStandardMacro... macros)
        Sets the macro set for the parser, replacing the macros from any prior call.
      • setStandardMacros

        @CanIgnoreReturnValue
        CelCompilerBuilder setStandardMacros​(java.lang.Iterable<CelStandardMacro> macros)
        Sets the macro set for the parser, replacing the macros from any prior call.
      • addMacros

        @CanIgnoreReturnValue
        CelCompilerBuilder addMacros​(CelMacro... macros)
        Registers the given macros, replacing any previous macros with the same key.

        Use this to register a set of user-defined custom macro implementation for the parser. For registering macros defined as part of CEL standard library, use setStandardMacros(dev.cel.parser.CelStandardMacro...) instead.

        Custom macros should not use the same function names as the ones found in CelStandardMacro (ex: has, all, exists, etc.). Build method will throw if both standard macros and custom macros are set with the same name.

      • addMacros

        @CanIgnoreReturnValue
        CelCompilerBuilder addMacros​(java.lang.Iterable<CelMacro> macros)
        Registers the given macros, replacing any previous macros with the same key.

        Use this to register a set of user-defined custom macro implementation for the parser. For registering macros defined as part of CEL standard library, use setStandardMacros(dev.cel.parser.CelStandardMacro...) instead.

        Custom macros should not use the same function names as the ones found in CelStandardMacro (ex: has, all, exists, etc.). Build method will throw if both standard macros and custom macros are set with the same name.

      • setOptions

        @CanIgnoreReturnValue
        CelCompilerBuilder setOptions​(CelOptions options)
        Set the CelOptions used to enable fixes and features for this CEL instances.
      • setContainer

        @CanIgnoreReturnValue
        CelCompilerBuilder setContainer​(java.lang.String container)
        Set the container name to use as the namespace for resolving CEL expression variables and functions.
      • addVar

        @CanIgnoreReturnValue
        CelCompilerBuilder addVar​(java.lang.String name,
                                  Type type)
        Add a variable declaration with a given name and proto based Type.
      • addDeclarations

        @CanIgnoreReturnValue
        CelCompilerBuilder addDeclarations​(Decl... declarations)
        Add variable and function declarations to the CEL environment.
      • addDeclarations

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

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

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

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

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

        @CanIgnoreReturnValue
        CelCompilerBuilder 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 to return the set of all fields declared on the protobuf type.

      • addProtoTypeMasks

        @CanIgnoreReturnValue
        CelCompilerBuilder 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 to return the set of all fields declared on the protobuf type.

      • setResultType

        @CanIgnoreReturnValue
        CelCompilerBuilder setResultType​(CelType resultType)
        Set the expected resultType for the type-checked expression.
      • setProtoResultType

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

        @CanIgnoreReturnValue
        CelCompilerBuilder setTypeProvider​(CelTypeProvider celTypeProvider)
        Set the celTypeProvider for use with type-checking expressions.
      • addMessageTypes

        @CanIgnoreReturnValue
        CelCompilerBuilder 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
        CelCompilerBuilder 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
        CelCompilerBuilder 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
        CelCompilerBuilder 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
        CelCompilerBuilder 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
        CelCompilerBuilder setStandardEnvironmentEnabled​(boolean value)
        Enable or disable the standard CEL library functions and variables
      • addLibraries

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

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