Package dev.cel.runtime
Class DefaultDispatcher
- java.lang.Object
-
- dev.cel.runtime.DefaultDispatcher
-
- All Implemented Interfaces:
Dispatcher,Registrar
@ThreadSafe @Internal public final class DefaultDispatcher extends java.lang.Object implements Dispatcher, Registrar
Default implementation ofDispatcher.Should be final, do not mock; mocking
Dispatcherinstead.CEL Library Internals. Do Not Use.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface dev.cel.runtime.Registrar
Registrar.BinaryFunction<T1,T2>, Registrar.Function, Registrar.UnaryFunction<T>
-
-
Constructor Summary
Constructors Constructor Description DefaultDispatcher(com.google.common.collect.ImmutableSet<ExprFeatures> features)Deprecated.useDefaultDispatcher(dev.cel.common.CelOptions)instead.DefaultDispatcher(CelOptions celOptions)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <T> voidadd(java.lang.String overloadId, java.lang.Class<T> argType, Registrar.UnaryFunction<T> function)Adds a unary function to the dispatcher.<T1,T2>
voidadd(java.lang.String overloadId, java.lang.Class<T1> argType1, java.lang.Class<T2> argType2, Registrar.BinaryFunction<T1,T2> function)Adds a binary function to the dispatcher.voidadd(java.lang.String overloadId, java.util.List<java.lang.Class<?>> argTypes, Registrar.Function function)Adds a general function to the dispatcher.static DefaultDispatchercreate()static DefaultDispatchercreate(com.google.common.collect.ImmutableSet<ExprFeatures> features)Deprecated.usecreate(CelOptions)instead.static DefaultDispatchercreate(CelOptions celOptions)static DefaultDispatchercreate(CelOptions celOptions, DynamicProto dynamicProto)java.lang.Objectdispatch(Metadata metadata, long exprId, java.lang.String functionName, java.util.List<java.lang.String> overloadIds, java.lang.Object[] args)Invokes a function based on given parameters.Dispatcher.ImmutableCopyimmutableCopy()Returns anDispatcher.ImmutableCopyfrom current instance.
-
-
-
Constructor Detail
-
DefaultDispatcher
@Deprecated public DefaultDispatcher(com.google.common.collect.ImmutableSet<ExprFeatures> features)
Deprecated.useDefaultDispatcher(dev.cel.common.CelOptions)instead.
-
DefaultDispatcher
public DefaultDispatcher(CelOptions celOptions)
-
-
Method Detail
-
create
@Deprecated public static DefaultDispatcher create(com.google.common.collect.ImmutableSet<ExprFeatures> features)
Deprecated.usecreate(CelOptions)instead.Creates a new dispatcher with all standard functions.
-
create
public static DefaultDispatcher create(CelOptions celOptions)
-
create
public static DefaultDispatcher create(CelOptions celOptions, DynamicProto dynamicProto)
-
create
public static DefaultDispatcher create()
-
add
public <T> void add(java.lang.String overloadId, java.lang.Class<T> argType, Registrar.UnaryFunction<T> function)Description copied from interface:RegistrarAdds a unary function to the dispatcher.
-
add
public <T1,T2> void add(java.lang.String overloadId, java.lang.Class<T1> argType1, java.lang.Class<T2> argType2, Registrar.BinaryFunction<T1,T2> function)Description copied from interface:RegistrarAdds a binary function to the dispatcher.
-
add
public void add(java.lang.String overloadId, java.util.List<java.lang.Class<?>> argTypes, Registrar.Function function)Description copied from interface:RegistrarAdds a general function to the dispatcher.
-
dispatch
public java.lang.Object dispatch(Metadata metadata, long exprId, java.lang.String functionName, java.util.List<java.lang.String> overloadIds, java.lang.Object[] args) throws InterpreterException
Description copied from interface:DispatcherInvokes a function based on given parameters.- Specified by:
dispatchin interfaceDispatcher- Parameters:
metadata- Metadata used for error reporting.exprId- Expression identifier which can be used together withmetadatato get information about the dispatch target for error reporting.functionName- the logical name of the function being invoked.overloadIds- A list of function overload ids. The dispatcher selects the unique overload from this list with matching arguments.args- The arguments to pass to the function.- Returns:
- The result of the function call.
- Throws:
InterpreterException- if something goes wrong.
-
immutableCopy
public Dispatcher.ImmutableCopy immutableCopy()
Description copied from interface:DispatcherReturns anDispatcher.ImmutableCopyfrom current instance.- Specified by:
immutableCopyin interfaceDispatcher- See Also:
Dispatcher.ImmutableCopy
-
-