org.faktorips.runtime.formula
Class FormulaEvaluatorUtil.FunctionWithListAsArgumentHelper<E>

java.lang.Object
  extended by 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 Summary
FormulaEvaluatorUtil.FunctionWithListAsArgumentHelper()
           
 
Method Summary
abstract  E getFallBackValue()
          Returns the value this function defaults to if an empty list or null is given as an argument.
abstract  E getPreliminaryResult(E currentResult, E nextValue)
          Calculates a preliminary result based on the current result and the next value in the list.
 E getResult(List<E> listOfValues)
          Returns the result of this function given a list of values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormulaEvaluatorUtil.FunctionWithListAsArgumentHelper

public FormulaEvaluatorUtil.FunctionWithListAsArgumentHelper()
Method Detail

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.


Copyright © 2015. All rights reserved.