Interface CelCompilerBuilder
-
- All Known Implementing Classes:
CelCompilerImpl.Builder
public interface CelCompilerBuilder
Interface for building an instance of CelCompiler
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description CelCompilerBuilder
addDeclarations(Decl... declarations)
Add variable and functiondeclarations
to the CEL environment.CelCompilerBuilder
addDeclarations(java.lang.Iterable<Decl> declarations)
Add variable and functiondeclarations
to the CEL environment.CelCompilerBuilder
addFileTypes(DescriptorProtos.FileDescriptorSet fileDescriptorSet)
Add all of theDescriptors.FileDescriptor
s in aFileDescriptorSet
to the use for type-checking, and for object creation at interpretation time.CelCompilerBuilder
addFileTypes(Descriptors.FileDescriptor... fileDescriptors)
AddDescriptors.FileDescriptor
s to the use for type-checking, and for object creation at interpretation time.CelCompilerBuilder
addFileTypes(java.lang.Iterable<Descriptors.FileDescriptor> fileDescriptors)
AddDescriptors.FileDescriptor
s to the use for type-checking, and for object creation at interpretation time.CelCompilerBuilder
addFunctionDeclarations(CelFunctionDecl... celFunctionDecls)
Add function declarationCelFunctionDecl
to the CEL environmentCelCompilerBuilder
addFunctionDeclarations(java.lang.Iterable<CelFunctionDecl> celFunctionDecls)
Add function declarationCelFunctionDecl
to the CEL environmentCelCompilerBuilder
addLibraries(CelCompilerLibrary... libraries)
Adds one or more libraries for parsing and type-checking.CelCompilerBuilder
addLibraries(java.lang.Iterable<? extends CelCompilerLibrary> libraries)
Adds a collection of libraries for parsing and type-checking.CelCompilerBuilder
addMacros(CelMacro... macros)
Registers the given macros, replacing any previous macros with the same key.CelCompilerBuilder
addMacros(java.lang.Iterable<CelMacro> macros)
Registers the given macros, replacing any previous macros with the same key.CelCompilerBuilder
addMessageTypes(Descriptors.Descriptor... descriptors)
Add messageDescriptors.Descriptor
s to the use for type-checking and object creation at interpretation time.CelCompilerBuilder
addMessageTypes(java.lang.Iterable<Descriptors.Descriptor> descriptors)
Add messageDescriptors.Descriptor
s to the use for type-checking and object creation at interpretation time.CelCompilerBuilder
addProtoTypeMasks(ProtoTypeMask... typeMasks)
Add one or moreProtoTypeMask
values.CelCompilerBuilder
addProtoTypeMasks(java.lang.Iterable<ProtoTypeMask> typeMasks)
Add one or moreProtoTypeMask
values.CelCompilerBuilder
addVar(java.lang.String name, CelType type)
Add a variable declaration with a givenname
andCelType
.CelCompilerBuilder
addVar(java.lang.String name, Type type)
Add a variable declaration with a givenname
and proto basedType
.CelCompilerBuilder
addVarDeclarations(CelVarDecl... varDecl)
Add variable declarationCelVarDecl
to the CEL environment.CelCompilerBuilder
addVarDeclarations(java.lang.Iterable<CelVarDecl> varDecl)
Add variable declarationCelVarDecl
to the CEL environment.CelCompiler
build()
Build a new instance of theCelCompiler
.CelCompilerBuilder
setContainer(java.lang.String container)
Set thecontainer
name to use as the namespace for resolving CEL expression variables and functions.CelCompilerBuilder
setOptions(CelOptions options)
Set theCelOptions
used to enable fixes and features for this CEL instances.CelCompilerBuilder
setProtoResultType(Type resultType)
Set the expectedresultType
in proto format described in checked.proto for the type-checked expression.CelCompilerBuilder
setResultType(CelType resultType)
Set the expectedresultType
for the type-checked expression.CelCompilerBuilder
setStandardEnvironmentEnabled(boolean value)
Enable or disable the standard CEL library functions and variablesCelCompilerBuilder
setStandardMacros(CelStandardMacro... macros)
Sets the macro set for the parser, replacing the macros from any prior call.CelCompilerBuilder
setStandardMacros(java.lang.Iterable<CelStandardMacro> macros)
Sets the macro set for the parser, replacing the macros from any prior call.CelCompilerBuilder
setTypeProvider(TypeProvider typeProvider)
Deprecated.UsesetTypeProvider(CelTypeProvider)
instead.CelCompilerBuilder
setTypeProvider(CelTypeProvider celTypeProvider)
Set thecelTypeProvider
for 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 theCelOptions
used to enable fixes and features for this CEL instances.
-
setContainer
@CanIgnoreReturnValue CelCompilerBuilder setContainer(java.lang.String container)
Set thecontainer
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 givenname
and proto basedType
.
-
addVar
@CanIgnoreReturnValue CelCompilerBuilder addVar(java.lang.String name, CelType type)
Add a variable declaration with a givenname
andCelType
.
-
addDeclarations
@CanIgnoreReturnValue CelCompilerBuilder addDeclarations(Decl... declarations)
Add variable and functiondeclarations
to the CEL environment.
-
addDeclarations
@CanIgnoreReturnValue CelCompilerBuilder addDeclarations(java.lang.Iterable<Decl> declarations)
Add variable and functiondeclarations
to the CEL environment.
-
addFunctionDeclarations
@CanIgnoreReturnValue CelCompilerBuilder addFunctionDeclarations(CelFunctionDecl... celFunctionDecls)
Add function declarationCelFunctionDecl
to the CEL environment
-
addFunctionDeclarations
@CanIgnoreReturnValue CelCompilerBuilder addFunctionDeclarations(java.lang.Iterable<CelFunctionDecl> celFunctionDecls)
Add function declarationCelFunctionDecl
to the CEL environment
-
addVarDeclarations
@CanIgnoreReturnValue CelCompilerBuilder addVarDeclarations(CelVarDecl... varDecl)
Add variable declarationCelVarDecl
to the CEL environment.
-
addVarDeclarations
@CanIgnoreReturnValue CelCompilerBuilder addVarDeclarations(java.lang.Iterable<CelVarDecl> varDecl)
Add variable declarationCelVarDecl
to the CEL environment.
-
addProtoTypeMasks
@CanIgnoreReturnValue CelCompilerBuilder addProtoTypeMasks(ProtoTypeMask... typeMasks)
Add one or moreProtoTypeMask
values. TheProtoTypeMask
values will be used to compute a set ofDecl
values 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
TypeProvider
implementations out of the box, as it requires the implementation ofTypeProvider#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 moreProtoTypeMask
values. TheProtoTypeMask
values will be used to compute a set ofDecl
values 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
TypeProvider
implementations out of the box, as it requires the implementation ofTypeProvider#lookupFieldNames
to return the set of all fields declared on the protobuf type.
-
setResultType
@CanIgnoreReturnValue CelCompilerBuilder setResultType(CelType resultType)
Set the expectedresultType
for the type-checked expression.
-
setProtoResultType
@CanIgnoreReturnValue CelCompilerBuilder setProtoResultType(Type resultType)
Set the expectedresultType
in proto format described in checked.proto for the type-checked expression.
-
setTypeProvider
@CanIgnoreReturnValue @Deprecated CelCompilerBuilder setTypeProvider(TypeProvider typeProvider)
Deprecated.UsesetTypeProvider(CelTypeProvider)
instead.Set thetypeProvider
for use with type-checking expressions.
-
setTypeProvider
@CanIgnoreReturnValue CelCompilerBuilder setTypeProvider(CelTypeProvider celTypeProvider)
Set thecelTypeProvider
for use with type-checking expressions.
-
addMessageTypes
@CanIgnoreReturnValue CelCompilerBuilder addMessageTypes(Descriptors.Descriptor... descriptors)
Add messageDescriptors.Descriptor
s to the use for type-checking and object creation at interpretation time.
-
addMessageTypes
@CanIgnoreReturnValue CelCompilerBuilder addMessageTypes(java.lang.Iterable<Descriptors.Descriptor> descriptors)
Add messageDescriptors.Descriptor
s to the use for type-checking and object creation at interpretation time.
-
addFileTypes
@CanIgnoreReturnValue CelCompilerBuilder addFileTypes(Descriptors.FileDescriptor... fileDescriptors)
AddDescriptors.FileDescriptor
s to the use for type-checking, and for object creation at interpretation time.
-
addFileTypes
@CanIgnoreReturnValue CelCompilerBuilder addFileTypes(java.lang.Iterable<Descriptors.FileDescriptor> fileDescriptors)
AddDescriptors.FileDescriptor
s to the use for type-checking, and for object creation at interpretation time.
-
addFileTypes
@CanIgnoreReturnValue CelCompilerBuilder addFileTypes(DescriptorProtos.FileDescriptorSet fileDescriptorSet)
Add all of theDescriptors.FileDescriptor
s in aFileDescriptorSet
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(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
.
-
-