Class ScalaFeelEngine
java.lang.Object
org.operaton.bpm.dmn.feel.impl.scala.ScalaFeelEngine
- All Implemented Interfaces:
FeelEngine
Implementation of the
FeelEngine interface to evaluate FEEL expressions
using the Scala FEEL engine.
This class provides functionalities for evaluating FEEL simple expressions and unary tests while allowing integration with custom function providers and value mappers.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.camunda.feel.api.FeelEngineApiProvides the underlying API implementation for evaluating FEEL (Friendly Enough Expression Language) expressions.protected static final ScalaFeelLogger -
Constructor Summary
ConstructorsConstructorDescriptionScalaFeelEngine(List<FeelCustomFunctionProvider> functionProviders) Constructs an instance of the ScalaFeelEngine. -
Method Summary
Modifier and TypeMethodDescriptionprotected org.camunda.feel.api.FeelEngineApibuildFeelEngineApi(CustomFunctionTransformer transformer, org.camunda.feel.valuemapper.ValueMapper.CompositeValueMapper valueMapper) Builds and initializes aFeelEngineApiinstance with configured custom function transformers and value mappers.<T> TevaluateSimpleExpression(String expression, VariableContext variableContext) Evaluates a simple FEEL (Friendly Enough Expression Language) expression using the provided variable context for resolving variables at runtime.booleanevaluateSimpleUnaryTests(String expression, String inputName, VariableContext variableContext) Evaluates a FEEL (Friendly Enough Expression Language) unary test expression against a given input variable using a variable context.protected camundajar.impl.scala.collection.immutable.List<org.camunda.feel.valuemapper.CustomValueMapper> Retrieves a list of custom value mappers to be used for value transformation or processing.protected <T> camundajar.impl.scala.collection.immutable.List<T> Converts a given Java List to a Scala List.protected final <T> camundajar.impl.scala.collection.immutable.List<T> toScalaList(T... elements) Converts a provided sequence of elements into a Scala-compatible `List`.
-
Field Details
-
LOGGER
-
feelEngineApi
protected final org.camunda.feel.api.FeelEngineApi feelEngineApiProvides the underlying API implementation for evaluating FEEL (Friendly Enough Expression Language) expressions. This object plays a central role within the ScalaFeelEngine class, enabling the evaluation of simple expressions, unary tests, and the transformation of custom functions or value mappings.It is initialized within the ScalaFeelEngine using a composite value mapper and custom function transformer. The API encapsulates the internal logic for processing FEEL expressions in compliance with DMN (Decision Model and Notation) standards.
This field is final, ensuring immutability and thread safety for consistent evaluation behavior throughout the lifespan of the ScalaFeelEngine instance.
-
-
Constructor Details
-
ScalaFeelEngine
Constructs an instance of the ScalaFeelEngine.- Parameters:
functionProviders- the list of custom function providers to be used when transforming and resolving functions in the FEEL engine. It allows the integration and registration of custom logic that can be executed as part of FEEL expressions.
-
-
Method Details
-
evaluateSimpleExpression
Evaluates a simple FEEL (Friendly Enough Expression Language) expression using the provided variable context for resolving variables at runtime.- Specified by:
evaluateSimpleExpressionin interfaceFeelEngine- Type Parameters:
T- the type of the result returned by the evaluation- Parameters:
expression- the FEEL expression to evaluate as a StringvariableContext- the variable context used to resolve variables within the expression- Returns:
- the result of the FEEL expression evaluation, cast to the specified type
- Throws:
FeelException- if the expression evaluation fails
-
evaluateSimpleUnaryTests
public boolean evaluateSimpleUnaryTests(String expression, String inputName, VariableContext variableContext) Evaluates a FEEL (Friendly Enough Expression Language) unary test expression against a given input variable using a variable context. This method is used to determine whether the input satisfies the specified unary test conditions.- Specified by:
evaluateSimpleUnaryTestsin interfaceFeelEngine- Parameters:
expression- the unary test expression to evaluateinputName- the name of the input variable to be resolved from the variable contextvariableContext- the context containing variables, used to resolve the input- Returns:
- true if the input variable satisfies the unary test conditions, false otherwise
-
getValueMappers
protected camundajar.impl.scala.collection.immutable.List<org.camunda.feel.valuemapper.CustomValueMapper> getValueMappers()Retrieves a list of custom value mappers to be used for value transformation or processing. The method creates a default Java value mapper and optionally includes a Spin value mapper if it can be instantiated successfully. The list is then converted into a Scala-compatible list.- Returns:
- a list of
CustomValueMapper, including the default Java value mapper and, if available, the Spin value mapper.
-
toScalaList
@SafeVarargs protected final <T> camundajar.impl.scala.collection.immutable.List<T> toScalaList(T... elements) Converts a provided sequence of elements into a Scala-compatible `List`. This method accepts a variable number of arguments and converts them into a Scala `List`, ensuring interoperability between Java and Scala data types.- Type Parameters:
T- the type of elements in the list- Parameters:
elements- a variable number of elements to be converted into a Scala list- Returns:
- a Scala-compatible `List` containing the given elements
-
toList
Converts a given Java List to a Scala List.- Type Parameters:
T- the type of elements in the list- Parameters:
list- the Java List to be converted- Returns:
- a Scala List containing the same elements as the provided Java List
-
buildFeelEngineApi
protected org.camunda.feel.api.FeelEngineApi buildFeelEngineApi(CustomFunctionTransformer transformer, org.camunda.feel.valuemapper.ValueMapper.CompositeValueMapper valueMapper) Builds and initializes aFeelEngineApiinstance with configured custom function transformers and value mappers. Disables external functions during the FEEL engine configuration.- Parameters:
transformer- theCustomFunctionTransformerto provide custom functions for the FEEL engine.valueMapper- theValueMapper.CompositeValueMapperfor transforming and processing values during FEEL evaluation.- Returns:
- a fully configured
FeelEngineApiinstance.
-