Package dev.cel.runtime
Class DefaultInterpreter
- java.lang.Object
-
- dev.cel.runtime.DefaultInterpreter
-
- All Implemented Interfaces:
Interpreter
@ThreadSafe @Internal public final class DefaultInterpreter extends java.lang.Object implements Interpreter
Default implementation of the CEL interpreter.Use as in:
MessageFactory messageFactory = new LinkedMessageFactory(); RuntimeTypeProvider typeProvider = new DescriptorMessageProvider(messageFactory); Dispatcher dispatcher = DefaultDispatcher.create(); Interpreter interpreter = new DefaultInterpreter(typeProvider, dispatcher); Interpretable interpretable = interpreter.createInterpretable(checkedExpr); Object result = interpretable.eval(Activation.of("name", value));Extensions functions can be added in addition to standard functions to the dispatcher as needed.
Note: {MessageFactory} instances may be combined using the
MessageFactory.CombinedMessageFactory.Note: On Android, the
DescriptorMessageProvideris not supported as proto lite does not support descriptors. Instead, implement theMessageProviderinterface directly.CEL Library Internals. Do Not Use.
-
-
Constructor Summary
Constructors Constructor Description DefaultInterpreter(RuntimeTypeProvider typeProvider, Dispatcher dispatcher)DefaultInterpreter(RuntimeTypeProvider typeProvider, Dispatcher dispatcher, CelOptions celOptions)Creates a new interpreter
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description InterpretablecreateInterpretable(CelAbstractSyntaxTree ast)Creates an interpretable for the given expression.InterpretablecreateInterpretable(CheckedExpr checkedExpr)Deprecated.
-
-
-
Constructor Detail
-
DefaultInterpreter
public DefaultInterpreter(RuntimeTypeProvider typeProvider, Dispatcher dispatcher)
-
DefaultInterpreter
public DefaultInterpreter(RuntimeTypeProvider typeProvider, Dispatcher dispatcher, CelOptions celOptions)
Creates a new interpreter- Parameters:
typeProvider- object which allows to construct and inspect messages.dispatcher- a method dispatcher.celOptions- the configurable flags for adjusting evaluation behavior.
-
-
Method Detail
-
createInterpretable
@Deprecated public Interpretable createInterpretable(CheckedExpr checkedExpr)
Deprecated.Description copied from interface:InterpreterCreates an interpretable for the given expression.This method may run pre-processing and partial evaluation of the expression it gets passed.
- Specified by:
createInterpretablein interfaceInterpreter
-
createInterpretable
public Interpretable createInterpretable(CelAbstractSyntaxTree ast)
Description copied from interface:InterpreterCreates an interpretable for the given expression.This method may run pre-processing and partial evaluation of the expression it gets passed.
- Specified by:
createInterpretablein interfaceInterpreter
-
-