org.faktorips.runtime.formula
Class FormulaEvaluatorUtil

java.lang.Object
  extended by org.faktorips.runtime.formula.FormulaEvaluatorUtil

public class FormulaEvaluatorUtil
extends Object

Provides methods that can be used in formula evaluation.

Some code in formulas does not need to be generated again and again but is implemented in static methods in this class that are used by the formulas.

Since:
3.6
Author:
Daniel Schwering, Faktor Zehn AG
See Also:
IFormulaEvaluator

Nested Class Summary
static class FormulaEvaluatorUtil.AssociationTo1Helper<S extends IModelObject,T extends IModelObject>
          Helper class for navigating 1-to-1 associations from a list of source objects of type <S> to target objects of type <T>.
static class FormulaEvaluatorUtil.AssociationToManyHelper<S extends IModelObject,T extends IModelObject>
          Helper class for navigating 1-to-many associations from a list of source objects of type <S> to target objects of type <T>.
static class FormulaEvaluatorUtil.AttributeAccessorHelper<S extends IModelObject,E>
          Helper class to get the values from a list of source objects of type <S> to target type <E>.
static class FormulaEvaluatorUtil.ExistsHelper
          Helper class to encapsulate a function call to verify the existence of an object that could result in an Exception (for example a NullPointerException or IndexOutOfBoundsException when navigating over associations in model objects) which should just be treated as a false result.
static class FormulaEvaluatorUtil.FunctionWithListAsArgumentHelper<E>
          Base class for functions working on list arguments.
 
Method Summary
static
<T extends IModelObject,R extends T>
List<? extends R>
getListModelObjectById(List<? extends T> modelObjects, String id)
          Returns all IConfigurableModelObject in the list that is configured by a IProductComponent with the given ID, the list is empty if no such object is found in the list.
static
<T extends IModelObject,R extends T>
R
getModelObjectById(List<? extends T> modelObjects, String id)
          Returns the (first) IConfigurableModelObject in the list that is configured by a IProductComponent with the given ID, null if no such object is found in the list.
static
<T extends IModelObject,R extends T>
R
getModelObjectById(T modelObject, String id)
          Returns the IModelObject if it is a IConfigurableModelObject configured by a IProductComponent with the given ID, null otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getModelObjectById

public static <T extends IModelObject,R extends T> R getModelObjectById(List<? extends T> modelObjects,
                                                                        String id)
Returns the (first) IConfigurableModelObject in the list that is configured by a IProductComponent with the given ID, null if no such object is found in the list.

Type Parameters:
T - the type of IModelObject returned by this method and expected in the list
Parameters:
modelObjects - a list of model objects of type
id - the runtime ID this method searches
Returns:
the (first) IConfigurableModelObject in the list that is configured by a IProductComponent with the given ID, null if no such object is found in the list
See Also:
getModelObjectById(IModelObject, String)

getListModelObjectById

public static <T extends IModelObject,R extends T> List<? extends R> getListModelObjectById(List<? extends T> modelObjects,
                                                                                            String id)
Returns all IConfigurableModelObject in the list that is configured by a IProductComponent with the given ID, the list is empty if no such object is found in the list.

Type Parameters:
T - the type of IModelObject returned by this method and expected in the list
Parameters:
modelObjects - a list of model objects of type
id - the runtime ID this method searches
Returns:
the all IConfigurableModelObject in the list that is configured by a IProductComponent with the given ID, the list is empty if no such object is found in the list
See Also:
getModelObjectById(IModelObject, String)

getModelObjectById

public static <T extends IModelObject,R extends T> R getModelObjectById(T modelObject,
                                                                        String id)
Returns the IModelObject if it is a IConfigurableModelObject configured by a IProductComponent with the given ID, null otherwise.

Type Parameters:
T - the type of IModelObject returned and expected by this method
Parameters:
modelObject - a model object of type
id - the runtime ID this method searches
Returns:
the IModelObject if it is a IConfigurableModelObject configured by a IProductComponent with the given ID, null otherwise
See Also:
getModelObjectById(List, String)


Copyright © 2015. All rights reserved.