Class ScalaFeelEngine

java.lang.Object
org.operaton.bpm.dmn.feel.impl.scala.ScalaFeelEngine
All Implemented Interfaces:
FeelEngine

public class ScalaFeelEngine extends Object implements 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

    Fields
    Modifier and Type
    Field
    Description
    protected final org.camunda.feel.api.FeelEngineApi
    Provides the underlying API implementation for evaluating FEEL (Friendly Enough Expression Language) expressions.
    protected static final ScalaFeelLogger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an instance of the ScalaFeelEngine.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.camunda.feel.api.FeelEngineApi
    buildFeelEngineApi(CustomFunctionTransformer transformer, org.camunda.feel.valuemapper.ValueMapper.CompositeValueMapper valueMapper)
    Builds and initializes a FeelEngineApi instance with configured custom function transformers and value mappers.
    <T> T
    evaluateSimpleExpression(String expression, VariableContext variableContext)
    Evaluates a simple FEEL (Friendly Enough Expression Language) expression using the provided variable context for resolving variables at runtime.
    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.
    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>
    toList(List<T> list)
    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`.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOGGER

      protected static final ScalaFeelLogger LOGGER
    • feelEngineApi

      protected final org.camunda.feel.api.FeelEngineApi feelEngineApi
      Provides 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

      public ScalaFeelEngine(List<FeelCustomFunctionProvider> functionProviders)
      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

      public <T> T evaluateSimpleExpression(String expression, VariableContext variableContext)
      Evaluates a simple FEEL (Friendly Enough Expression Language) expression using the provided variable context for resolving variables at runtime.
      Specified by:
      evaluateSimpleExpression in interface FeelEngine
      Type Parameters:
      T - the type of the result returned by the evaluation
      Parameters:
      expression - the FEEL expression to evaluate as a String
      variableContext - 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:
      evaluateSimpleUnaryTests in interface FeelEngine
      Parameters:
      expression - the unary test expression to evaluate
      inputName - the name of the input variable to be resolved from the variable context
      variableContext - 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

      protected <T> camundajar.impl.scala.collection.immutable.List<T> toList(List<T> list)
      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 a FeelEngineApi instance with configured custom function transformers and value mappers. Disables external functions during the FEEL engine configuration.
      Parameters:
      transformer - the CustomFunctionTransformer to provide custom functions for the FEEL engine.
      valueMapper - the ValueMapper.CompositeValueMapper for transforming and processing values during FEEL evaluation.
      Returns:
      a fully configured FeelEngineApi instance.