Class CalculationParameters

  • All Implemented Interfaces:
    Serializable, org.joda.beans.Bean, org.joda.beans.ImmutableBean

    public final class CalculationParameters
    extends Object
    implements org.joda.beans.ImmutableBean, Serializable
    The calculation parameters.

    This provides a set of parameters that will be used in a calculation. Each parameter defines a query type, thus the functions are keyed in a Map by the query type Class.

    Parameters exist to provide control over the calculation. For example, ReportingCurrency is a parameter that controls currency conversion. If specified, on a Column, or in CalculationRules, then the output will be converted to the specified currency.

    See Also:
    Serialized Form
    • Method Detail

      • empty

        public static CalculationParameters empty()
        Obtains an empty instance with no parameters.
        Returns:
        the empty instance
      • combinedWith

        public CalculationParameters combinedWith​(CalculationParameters other)
        Combines this set of parameters with the specified set.

        This set of parameters takes priority.

        Parameters:
        other - the other parameters
        Returns:
        the combined calculation parameters
      • with

        public CalculationParameters with​(CalculationParameter parameter)
        Returns a copy of this instance with the specified parameter added.

        If this instance already has a parameter with the query type, it will be replaced.

        Parameters:
        parameter - the parameter to add
        Returns:
        the new instance based on this with the parameter added
      • without

        public CalculationParameters without​(Class<? extends CalculationParameter> type)
        Filters the parameters, returning a set without the specified type.
        Parameters:
        type - the type to remove
        Returns:
        the filtered calculation parameters
      • filter

        public CalculationParameters filter​(CalculationTarget target,
                                            Measure measure)
        Filters the parameters, matching only those that are applicable for the target and measure.

        The resulting parameters are filtered to the target and measure. The implementation of each parameter may be changed by this process. If two parameters are filtered to the same query type then an exception will be thrown

        Parameters:
        target - the calculation target, such as a trade
        measure - the measure to be calculated
        Returns:
        the filtered calculation parameters
        Throws:
        IllegalArgumentException - if two parameters are filtered to the same query type
      • findParameter

        public <T extends CalculationParameterOptional<T> findParameter​(Class<T> type)
        Finds the parameter that matches the specified query type.

        This method may throw an exception if the parameters have not been filtered.

        Type Parameters:
        T - the type of the parameter
        Parameters:
        type - the query type to find
        Returns:
        the parameter
      • getParameter

        public <T extends CalculationParameter> T getParameter​(Class<T> type)
        Returns the parameter that matches the specified query type throwing an exception if not available.

        This method may throw an exception if the parameters have not been filtered.

        Type Parameters:
        T - the type of the parameter
        Parameters:
        type - the query type to return
        Returns:
        the parameter
        Throws:
        IllegalArgumentException - if no parameter if found for the type
      • meta

        public static org.joda.beans.TypedMetaBean<CalculationParameters> meta()
        The meta-bean for CalculationParameters.
        Returns:
        the meta-bean, not null
      • metaBean

        public org.joda.beans.TypedMetaBean<CalculationParameters> metaBean()
        Specified by:
        metaBean in interface org.joda.beans.Bean
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object