Class FormulaEvaluatorUtil.FunctionWithListAsArgumentHelper<E>

java.lang.Object
org.faktorips.runtime.formula.FormulaEvaluatorUtil.FunctionWithListAsArgumentHelper<E>
Enclosing class:
FormulaEvaluatorUtil

public abstract static class FormulaEvaluatorUtil.FunctionWithListAsArgumentHelper<E> extends Object
Base class for functions working on list arguments. Subclasses define the function by overwriting getPreliminaryResult(Object, Object) and getFallBackValue().
Author:
HBaagil
  • Constructor Details

    • FunctionWithListAsArgumentHelper

      public FunctionWithListAsArgumentHelper()
  • Method Details

    • getResult

      public E getResult(List<E> listOfValues)
      Returns the result of this function given a list of values.
      Parameters:
      listOfValues - A List of values.
    • getFallBackValue

      public abstract E getFallBackValue()
      Returns the value this function defaults to if an empty list or null is given as an argument. E.g. for the function sum, the fall back value is 0.
    • getPreliminaryResult

      public abstract E getPreliminaryResult(E currentResult, E nextValue)
      Calculates a preliminary result based on the current result and the next value in the list.
      Parameters:
      currentResult - The current result calculated up to this point.
      nextValue - The value to be considered next.
      Returns:
      The result of the operation defined by subclasses.