Package org.faktorips.runtime.formula
Class AbstractFormulaEvaluator
- java.lang.Object
-
- org.faktorips.runtime.formula.AbstractFormulaEvaluator
-
- All Implemented Interfaces:
IFormulaEvaluator
public abstract class AbstractFormulaEvaluator extends java.lang.Object implements IFormulaEvaluator
An abstract implementation ofIFormulaEvaluatorholding the product component generation or product component and handles the exceptions thrown by theevaluateInternal(String, Object...)method.There is no method to set the compiled formula expression because the expressions have to be set by the
IFormulaEvaluatorFactorywhile creating the evaluator.- Author:
- dirmeier
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCOMPILED_EXPRESSION_XML_TAG
-
Constructor Summary
Constructors Constructor Description AbstractFormulaEvaluator(java.lang.Object object, java.util.Map<java.lang.String,java.lang.String> nameToExpressionMap)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Objectevaluate(java.lang.String formularName, java.lang.Object... parameters)Evaluates a formula that was added through the builderprotected abstract java.lang.ObjectevaluateInternal(java.lang.String formularName, java.lang.Object... parameters)This method evaluates the formula with the given name and the specified parameters.java.util.Map<java.lang.String,java.lang.String>getNameToExpressionMap()Returns a defensive copy of the map of expressions/formulas held by this evaluator.java.lang.ObjectgetObject()Returns the product component generation or product component this is an evaluator for.
-
-
-
Field Detail
-
COMPILED_EXPRESSION_XML_TAG
public static final java.lang.String COMPILED_EXPRESSION_XML_TAG
- See Also:
- Constant Field Values
-
-
Method Detail
-
getObject
public java.lang.Object getObject()
Description copied from interface:IFormulaEvaluatorReturns the product component generation or product component this is an evaluator for.- Specified by:
getObjectin interfaceIFormulaEvaluator
-
evaluate
public java.lang.Object evaluate(java.lang.String formularName, java.lang.Object... parameters)Evaluates a formula that was added through the builder- Specified by:
evaluatein interfaceIFormulaEvaluator- Parameters:
formularName- The name of the formula to evaluateparameters- the parameters the formula requires when being evaluated- Returns:
- the result of the evaluated formula
- Throws:
java.lang.IllegalArgumentException- if the formula signature is unknown
-
evaluateInternal
protected abstract java.lang.Object evaluateInternal(java.lang.String formularName, java.lang.Object... parameters) throws java.lang.ExceptionThis 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 evaluateparameters- the parameters to evaluate the formula- Returns:
- the return value of the evaluated formula
- Throws:
java.lang.Exception
-
getNameToExpressionMap
public java.util.Map<java.lang.String,java.lang.String> getNameToExpressionMap()
Returns a defensive copy of the map of expressions/formulas held by this evaluator.- Specified by:
getNameToExpressionMapin interfaceIFormulaEvaluator- Returns:
- a map containing the expressions (with their names as keys) held by this formula evaluator
-
-