Class AbstractFormulaEvaluator

java.lang.Object
org.faktorips.runtime.formula.AbstractFormulaEvaluator
All Implemented Interfaces:
IFormulaEvaluator

public abstract class AbstractFormulaEvaluator extends Object implements IFormulaEvaluator
An abstract implementation of IFormulaEvaluator holding the product component generation or product component and handles the exceptions thrown by the evaluateInternal(String, Object...) method.

There is no method to set the compiled formula expression because the expressions have to be set by the IFormulaEvaluatorFactory while creating the evaluator.

Author:
dirmeier
  • Field Details

  • Constructor Details

    • AbstractFormulaEvaluator

      public AbstractFormulaEvaluator(Object object, Map<String,String> nameToExpressionMap)
  • Method Details

    • getObject

      public Object getObject()
      Description copied from interface: IFormulaEvaluator
      Returns the product component generation or product component this is an evaluator for.
      Specified by:
      getObject in interface IFormulaEvaluator
    • evaluate

      public Object evaluate(String formularName, Object... parameters)
      Evaluates a formula that was added through the builder
      Specified by:
      evaluate in interface IFormulaEvaluator
      Parameters:
      formularName - The name of the formula to evaluate
      parameters - the parameters the formula requires when being evaluated
      Returns:
      the result of the evaluated formula
      Throws:
      IllegalArgumentException - if the formula signature is unknown
    • evaluateInternal

      protected abstract Object evaluateInternal(String formularName, Object... parameters) throws Exception
      This method evaluates the formula with the given name and the specified parameters. With the name and parameters you have the complete formula method signature. The order of the parameters is given by the formula signature.
      Parameters:
      formularName - name of the formula to evaluate
      parameters - the parameters to evaluate the formula
      Returns:
      the return value of the evaluated formula
      Throws:
      Exception
    • getNameToExpressionMap

      public Map<String,String> getNameToExpressionMap()
      Returns a defensive copy of the map of expressions/formulas held by this evaluator.
      Specified by:
      getNameToExpressionMap in interface IFormulaEvaluator
      Returns:
      a map containing the expressions (with their names as keys) held by this formula evaluator