Class CelCompilerImpl.Builder
- java.lang.Object
-
- dev.cel.compiler.CelCompilerImpl.Builder
-
- All Implemented Interfaces:
CelCompilerBuilder
- Enclosing class:
- CelCompilerImpl
public static final class CelCompilerImpl.Builder extends java.lang.Object implements CelCompilerBuilder
Builder forCelCompilerImpl
-
-
Method Summary
All Methods Instance Methods Concrete 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(com.google.protobuf.DescriptorProtos.FileDescriptorSet fileDescriptorSet)Add all of theDescriptors.FileDescriptors in aFileDescriptorSetto the use for type-checking, and for object creation at interpretation time.CelCompilerBuilderaddFileTypes(com.google.protobuf.Descriptors.FileDescriptor... fileDescriptors)AddDescriptors.FileDescriptors to the use for type-checking, and for object creation at interpretation time.CelCompilerBuilderaddFileTypes(java.lang.Iterable<com.google.protobuf.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(com.google.protobuf.Descriptors.Descriptor... descriptors)Add messageDescriptors.Descriptors to the use for type-checking and object creation at interpretation time.CelCompilerBuilderaddMessageTypes(java.lang.Iterable<com.google.protobuf.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... celVarDecls)Add variable declarationCelVarDeclto the CEL environment.CelCompilerBuilderaddVarDeclarations(java.lang.Iterable<CelVarDecl> celVarDecls)Add variable declarationCelVarDeclto the CEL environment.CelCompilerImplbuild()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.CelCompilerBuildersetStandardDeclarations(CelStandardDeclarations standardDeclarations)Override the standard declarations for the type-checker.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.CelCompilerBuildersetTypeProvider(CelTypeProvider celTypeProvider)Set thecelTypeProviderfor use with type-checking expressions.
-
-
-
Method Detail
-
setOptions
public CelCompilerBuilder setOptions(CelOptions options)
Description copied from interface:CelCompilerBuilderSet theCelOptionsused to enable fixes and features for this CEL instances.- Specified by:
setOptionsin interfaceCelCompilerBuilder
-
setStandardMacros
public CelCompilerBuilder setStandardMacros(CelStandardMacro... macros)
Description copied from interface:CelCompilerBuilderSets the macro set for the parser, replacing the macros from any prior call.- Specified by:
setStandardMacrosin interfaceCelCompilerBuilder
-
setStandardMacros
public CelCompilerBuilder setStandardMacros(java.lang.Iterable<CelStandardMacro> macros)
Description copied from interface:CelCompilerBuilderSets the macro set for the parser, replacing the macros from any prior call.- Specified by:
setStandardMacrosin interfaceCelCompilerBuilder
-
addMacros
public CelCompilerBuilder addMacros(CelMacro... macros)
Description copied from interface:CelCompilerBuilderRegisters 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
CelCompilerBuilder.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.- Specified by:
addMacrosin interfaceCelCompilerBuilder
-
addMacros
public CelCompilerBuilder addMacros(java.lang.Iterable<CelMacro> macros)
Description copied from interface:CelCompilerBuilderRegisters 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
CelCompilerBuilder.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.- Specified by:
addMacrosin interfaceCelCompilerBuilder
-
setContainer
public CelCompilerBuilder setContainer(java.lang.String container)
Description copied from interface:CelCompilerBuilderSet thecontainername to use as the namespace for resolving CEL expression variables and functions.- Specified by:
setContainerin interfaceCelCompilerBuilder
-
addVar
public CelCompilerBuilder addVar(java.lang.String name, Type type)
Description copied from interface:CelCompilerBuilderAdd a variable declaration with a givennameand proto basedType.- Specified by:
addVarin interfaceCelCompilerBuilder
-
addVar
public CelCompilerBuilder addVar(java.lang.String name, CelType type)
Description copied from interface:CelCompilerBuilderAdd a variable declaration with a givennameandCelType.- Specified by:
addVarin interfaceCelCompilerBuilder
-
addDeclarations
public CelCompilerBuilder addDeclarations(Decl... declarations)
Description copied from interface:CelCompilerBuilderAdd variable and functiondeclarationsto the CEL environment.- Specified by:
addDeclarationsin interfaceCelCompilerBuilder
-
addDeclarations
public CelCompilerBuilder addDeclarations(java.lang.Iterable<Decl> declarations)
Description copied from interface:CelCompilerBuilderAdd variable and functiondeclarationsto the CEL environment.- Specified by:
addDeclarationsin interfaceCelCompilerBuilder
-
addFunctionDeclarations
public CelCompilerBuilder addFunctionDeclarations(CelFunctionDecl... celFunctionDecls)
Description copied from interface:CelCompilerBuilderAdd function declarationCelFunctionDeclto the CEL environment- Specified by:
addFunctionDeclarationsin interfaceCelCompilerBuilder
-
addFunctionDeclarations
public CelCompilerBuilder addFunctionDeclarations(java.lang.Iterable<CelFunctionDecl> celFunctionDecls)
Description copied from interface:CelCompilerBuilderAdd function declarationCelFunctionDeclto the CEL environment- Specified by:
addFunctionDeclarationsin interfaceCelCompilerBuilder
-
addVarDeclarations
public CelCompilerBuilder addVarDeclarations(CelVarDecl... celVarDecls)
Description copied from interface:CelCompilerBuilderAdd variable declarationCelVarDeclto the CEL environment.- Specified by:
addVarDeclarationsin interfaceCelCompilerBuilder
-
addVarDeclarations
public CelCompilerBuilder addVarDeclarations(java.lang.Iterable<CelVarDecl> celVarDecls)
Description copied from interface:CelCompilerBuilderAdd variable declarationCelVarDeclto the CEL environment.- Specified by:
addVarDeclarationsin interfaceCelCompilerBuilder
-
addProtoTypeMasks
public CelCompilerBuilder addProtoTypeMasks(ProtoTypeMask... typeMasks)
Description copied from interface:CelCompilerBuilderAdd 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.- Specified by:
addProtoTypeMasksin interfaceCelCompilerBuilder
-
addProtoTypeMasks
public CelCompilerBuilder addProtoTypeMasks(java.lang.Iterable<ProtoTypeMask> typeMasks)
Description copied from interface:CelCompilerBuilderAdd 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.- Specified by:
addProtoTypeMasksin interfaceCelCompilerBuilder
-
setResultType
public CelCompilerBuilder setResultType(CelType resultType)
Description copied from interface:CelCompilerBuilderSet the expectedresultTypefor the type-checked expression.- Specified by:
setResultTypein interfaceCelCompilerBuilder
-
setProtoResultType
public CelCompilerBuilder setProtoResultType(Type resultType)
Description copied from interface:CelCompilerBuilderSet the expectedresultTypein proto format described in checked.proto for the type-checked expression.- Specified by:
setProtoResultTypein interfaceCelCompilerBuilder
-
setTypeProvider
@Deprecated public CelCompilerBuilder setTypeProvider(TypeProvider typeProvider)
Deprecated.Description copied from interface:CelCompilerBuilderSet thetypeProviderfor use with type-checking expressions.- Specified by:
setTypeProviderin interfaceCelCompilerBuilder
-
setTypeProvider
public CelCompilerBuilder setTypeProvider(CelTypeProvider celTypeProvider)
Description copied from interface:CelCompilerBuilderSet thecelTypeProviderfor use with type-checking expressions.- Specified by:
setTypeProviderin interfaceCelCompilerBuilder
-
addMessageTypes
public CelCompilerBuilder addMessageTypes(com.google.protobuf.Descriptors.Descriptor... descriptors)
Description copied from interface:CelCompilerBuilderAdd messageDescriptors.Descriptors to the use for type-checking and object creation at interpretation time.- Specified by:
addMessageTypesin interfaceCelCompilerBuilder
-
addMessageTypes
public CelCompilerBuilder addMessageTypes(java.lang.Iterable<com.google.protobuf.Descriptors.Descriptor> descriptors)
Description copied from interface:CelCompilerBuilderAdd messageDescriptors.Descriptors to the use for type-checking and object creation at interpretation time.- Specified by:
addMessageTypesin interfaceCelCompilerBuilder
-
addFileTypes
public CelCompilerBuilder addFileTypes(com.google.protobuf.Descriptors.FileDescriptor... fileDescriptors)
Description copied from interface:CelCompilerBuilderAddDescriptors.FileDescriptors to the use for type-checking, and for object creation at interpretation time.- Specified by:
addFileTypesin interfaceCelCompilerBuilder
-
addFileTypes
public CelCompilerBuilder addFileTypes(java.lang.Iterable<com.google.protobuf.Descriptors.FileDescriptor> fileDescriptors)
Description copied from interface:CelCompilerBuilderAddDescriptors.FileDescriptors to the use for type-checking, and for object creation at interpretation time.- Specified by:
addFileTypesin interfaceCelCompilerBuilder
-
addFileTypes
public CelCompilerBuilder addFileTypes(com.google.protobuf.DescriptorProtos.FileDescriptorSet fileDescriptorSet)
Description copied from interface:CelCompilerBuilderAdd all of theDescriptors.FileDescriptors in aFileDescriptorSetto the use for type-checking, and for object creation at interpretation time.- Specified by:
addFileTypesin interfaceCelCompilerBuilder
-
setStandardEnvironmentEnabled
public CelCompilerBuilder setStandardEnvironmentEnabled(boolean value)
Description copied from interface:CelCompilerBuilderEnable or disable the standard CEL library functions and variables- Specified by:
setStandardEnvironmentEnabledin interfaceCelCompilerBuilder
-
setStandardDeclarations
public CelCompilerBuilder setStandardDeclarations(CelStandardDeclarations standardDeclarations)
Description copied from interface:CelCompilerBuilderOverride 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.CelCompilerBuilder.setStandardEnvironmentEnabled(boolean)must be set to false for this to take effect.- Specified by:
setStandardDeclarationsin interfaceCelCompilerBuilder
-
addLibraries
public CelCompilerBuilder addLibraries(CelCompilerLibrary... libraries)
Description copied from interface:CelCompilerBuilderAdds one or more libraries for parsing and type-checking.- Specified by:
addLibrariesin interfaceCelCompilerBuilder
-
addLibraries
public CelCompilerBuilder addLibraries(java.lang.Iterable<? extends CelCompilerLibrary> libraries)
Description copied from interface:CelCompilerBuilderAdds a collection of libraries for parsing and type-checking.- Specified by:
addLibrariesin interfaceCelCompilerBuilder
-
build
@CheckReturnValue public CelCompilerImpl build()
Description copied from interface:CelCompilerBuilderBuild a new instance of theCelCompiler.- Specified by:
buildin interfaceCelCompilerBuilder
-
-