Interface CelCompilerBuilder
-
- All Known Implementing Classes:
CelCompilerImpl.Builder
public interface CelCompilerBuilderInterface for building an instance of CelCompiler
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description CelCompilerBuilderaddDeclarations(Decl... declarations)Add variable and functiondeclarationsto the CEL environment.CelCompilerBuilderaddDeclarations(java.lang.Iterable<Decl> declarations)Add variable and functiondeclarationsto the CEL environment.CelCompilerBuilderaddFileTypes(DescriptorProtos.FileDescriptorSet fileDescriptorSet)Add all of theDescriptors.FileDescriptors in aFileDescriptorSetto the use for type-checking, and for object creation at interpretation time.CelCompilerBuilderaddFileTypes(Descriptors.FileDescriptor... fileDescriptors)AddDescriptors.FileDescriptors to the use for type-checking, and for object creation at interpretation time.CelCompilerBuilderaddFileTypes(java.lang.Iterable<Descriptors.FileDescriptor> fileDescriptors)AddDescriptors.FileDescriptors to the use for type-checking, and for object creation at interpretation time.CelCompilerBuilderaddFunctionDeclarations(CelFunctionDecl... celFunctionDecls)Add function declarationCelFunctionDeclto the CEL environmentCelCompilerBuilderaddFunctionDeclarations(java.lang.Iterable<CelFunctionDecl> celFunctionDecls)Add function declarationCelFunctionDeclto the CEL environmentCelCompilerBuilderaddLibraries(CelCompilerLibrary... libraries)Adds one or more libraries for parsing and type-checking.CelCompilerBuilderaddLibraries(java.lang.Iterable<? extends CelCompilerLibrary> libraries)Adds a collection of libraries for parsing and type-checking.CelCompilerBuilderaddMacros(CelMacro... macros)Registers the given macros, replacing any previous macros with the same key.CelCompilerBuilderaddMacros(java.lang.Iterable<CelMacro> macros)Registers the given macros, replacing any previous macros with the same key.CelCompilerBuilderaddMessageTypes(Descriptors.Descriptor... descriptors)Add messageDescriptors.Descriptors to the use for type-checking and object creation at interpretation time.CelCompilerBuilderaddMessageTypes(java.lang.Iterable<Descriptors.Descriptor> descriptors)Add messageDescriptors.Descriptors to the use for type-checking and object creation at interpretation time.CelCompilerBuilderaddProtoTypeMasks(ProtoTypeMask... typeMasks)Add one or moreProtoTypeMaskvalues.CelCompilerBuilderaddProtoTypeMasks(java.lang.Iterable<ProtoTypeMask> typeMasks)Add one or moreProtoTypeMaskvalues.CelCompilerBuilderaddVar(java.lang.String name, CelType type)Add a variable declaration with a givennameandCelType.CelCompilerBuilderaddVar(java.lang.String name, Type type)Add a variable declaration with a givennameand proto basedType.CelCompilerBuilderaddVarDeclarations(CelVarDecl... varDecl)Add variable declarationCelVarDeclto the CEL environment.CelCompilerBuilderaddVarDeclarations(java.lang.Iterable<CelVarDecl> varDecl)Add variable declarationCelVarDeclto the CEL environment.CelCompilerbuild()Build a new instance of theCelCompiler.CelCompilerBuildersetContainer(java.lang.String container)Set thecontainername to use as the namespace for resolving CEL expression variables and functions.CelCompilerBuildersetOptions(CelOptions options)Set theCelOptionsused to enable fixes and features for this CEL instances.CelCompilerBuildersetProtoResultType(Type resultType)Set the expectedresultTypein proto format described in checked.proto for the type-checked expression.CelCompilerBuildersetResultType(CelType resultType)Set the expectedresultTypefor the type-checked expression.CelCompilerBuildersetStandardEnvironmentEnabled(boolean value)Enable or disable the standard CEL library functions and variablesCelCompilerBuildersetStandardMacros(CelStandardMacro... macros)Sets the macro set for the parser, replacing the macros from any prior call.CelCompilerBuildersetStandardMacros(java.lang.Iterable<CelStandardMacro> macros)Sets the macro set for the parser, replacing the macros from any prior call.CelCompilerBuildersetTypeProvider(TypeProvider typeProvider)Deprecated.UsesetTypeProvider(CelTypeProvider)instead.CelCompilerBuildersetTypeProvider(CelTypeProvider celTypeProvider)Set thecelTypeProviderfor use with type-checking expressions.
-
-
-
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 theCelOptionsused to enable fixes and features for this CEL instances.
-
setContainer
@CanIgnoreReturnValue CelCompilerBuilder setContainer(java.lang.String container)
Set thecontainername 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 givennameand proto basedType.
-
addVar
@CanIgnoreReturnValue CelCompilerBuilder addVar(java.lang.String name, CelType type)
Add a variable declaration with a givennameandCelType.
-
addDeclarations
@CanIgnoreReturnValue CelCompilerBuilder addDeclarations(Decl... declarations)
Add variable and functiondeclarationsto the CEL environment.
-
addDeclarations
@CanIgnoreReturnValue CelCompilerBuilder addDeclarations(java.lang.Iterable<Decl> declarations)
Add variable and functiondeclarationsto the CEL environment.
-
addFunctionDeclarations
@CanIgnoreReturnValue CelCompilerBuilder addFunctionDeclarations(CelFunctionDecl... celFunctionDecls)
Add function declarationCelFunctionDeclto the CEL environment
-
addFunctionDeclarations
@CanIgnoreReturnValue CelCompilerBuilder addFunctionDeclarations(java.lang.Iterable<CelFunctionDecl> celFunctionDecls)
Add function declarationCelFunctionDeclto the CEL environment
-
addVarDeclarations
@CanIgnoreReturnValue CelCompilerBuilder addVarDeclarations(CelVarDecl... varDecl)
Add variable declarationCelVarDeclto the CEL environment.
-
addVarDeclarations
@CanIgnoreReturnValue CelCompilerBuilder addVarDeclarations(java.lang.Iterable<CelVarDecl> varDecl)
Add variable declarationCelVarDeclto the CEL environment.
-
addProtoTypeMasks
@CanIgnoreReturnValue CelCompilerBuilder addProtoTypeMasks(ProtoTypeMask... typeMasks)
Add one or moreProtoTypeMaskvalues. TheProtoTypeMaskvalues will be used to compute a set ofDeclvalues using a protobuf message's fields as the names and types of the variables ifProtoTypeMask.fieldsAreVariableDeclarations()istrue.Note, this feature may not work with custom
TypeProviderimplementations out of the box, as it requires the implementation ofTypeProvider#lookupFieldNamesto return the set of all fields declared on the protobuf type.
-
addProtoTypeMasks
@CanIgnoreReturnValue CelCompilerBuilder addProtoTypeMasks(java.lang.Iterable<ProtoTypeMask> typeMasks)
Add one or moreProtoTypeMaskvalues. TheProtoTypeMaskvalues will be used to compute a set ofDeclvalues using a protobuf message's fields as the names and types of the variables ifProtoTypeMask.fieldsAreVariableDeclarations()istrue.Note, this feature may not work with custom
TypeProviderimplementations out of the box, as it requires the implementation ofTypeProvider#lookupFieldNamesto return the set of all fields declared on the protobuf type.
-
setResultType
@CanIgnoreReturnValue CelCompilerBuilder setResultType(CelType resultType)
Set the expectedresultTypefor the type-checked expression.
-
setProtoResultType
@CanIgnoreReturnValue CelCompilerBuilder setProtoResultType(Type resultType)
Set the expectedresultTypein proto format described in checked.proto for the type-checked expression.
-
setTypeProvider
@CanIgnoreReturnValue @Deprecated CelCompilerBuilder setTypeProvider(TypeProvider typeProvider)
Deprecated.UsesetTypeProvider(CelTypeProvider)instead.Set thetypeProviderfor use with type-checking expressions.
-
setTypeProvider
@CanIgnoreReturnValue CelCompilerBuilder setTypeProvider(CelTypeProvider celTypeProvider)
Set thecelTypeProviderfor use with type-checking expressions.
-
addMessageTypes
@CanIgnoreReturnValue CelCompilerBuilder addMessageTypes(Descriptors.Descriptor... descriptors)
Add messageDescriptors.Descriptors to the use for type-checking and object creation at interpretation time.
-
addMessageTypes
@CanIgnoreReturnValue CelCompilerBuilder addMessageTypes(java.lang.Iterable<Descriptors.Descriptor> descriptors)
Add messageDescriptors.Descriptors to the use for type-checking and object creation at interpretation time.
-
addFileTypes
@CanIgnoreReturnValue CelCompilerBuilder addFileTypes(Descriptors.FileDescriptor... fileDescriptors)
AddDescriptors.FileDescriptors to the use for type-checking, and for object creation at interpretation time.
-
addFileTypes
@CanIgnoreReturnValue CelCompilerBuilder addFileTypes(java.lang.Iterable<Descriptors.FileDescriptor> fileDescriptors)
AddDescriptors.FileDescriptors to the use for type-checking, and for object creation at interpretation time.
-
addFileTypes
@CanIgnoreReturnValue CelCompilerBuilder addFileTypes(DescriptorProtos.FileDescriptorSet fileDescriptorSet)
Add all of theDescriptors.FileDescriptors in aFileDescriptorSetto 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(CelCompilerLibrary... libraries)
Adds one or more libraries for parsing and type-checking.
-
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 theCelCompiler.
-
-