Class 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 DescriptorMessageProvider is not supported as proto lite does not support descriptors. Instead, implement the MessageProvider interface directly.

    CEL Library Internals. Do Not Use.

    • Constructor Detail

      • 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: Interpreter
        Creates an interpretable for the given expression.

        This method may run pre-processing and partial evaluation of the expression it gets passed.

        Specified by:
        createInterpretable in interface Interpreter