Class CalculationParameters
- java.lang.Object
-
- com.opengamma.strata.calc.runner.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 typeClass
.Parameters exist to provide control over the calculation. For example,
ReportingCurrency
is a parameter that controls currency conversion. If specified, on aColumn
, or inCalculationRules
, then the output will be converted to the specified currency.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CalculationParameters
combinedWith(CalculationParameters other)
Combines this set of parameters with the specified set.static CalculationParameters
empty()
Obtains an empty instance with no parameters.boolean
equals(Object obj)
CalculationParameters
filter(CalculationTarget target, Measure measure)
Filters the parameters, matching only those that are applicable for the target and measure.<T extends CalculationParameter>
Optional<T>findParameter(Class<T> type)
Finds the parameter that matches the specified query type.<T extends CalculationParameter>
TgetParameter(Class<T> type)
Returns the parameter that matches the specified query type throwing an exception if not available.ImmutableMap<Class<? extends CalculationParameter>,CalculationParameter>
getParameters()
Gets the parameters, keyed by query type.int
hashCode()
static org.joda.beans.TypedMetaBean<CalculationParameters>
meta()
The meta-bean forCalculationParameters
.org.joda.beans.TypedMetaBean<CalculationParameters>
metaBean()
static CalculationParameters
of(CalculationParameter... parameters)
Obtains an instance from the specified parameters.static CalculationParameters
of(List<? extends CalculationParameter> parameters)
Obtains an instance from the specified parameters.String
toString()
CalculationParameters
with(CalculationParameter parameter)
Returns a copy of this instance with the specified parameter added.CalculationParameters
without(Class<? extends CalculationParameter> type)
Filters the parameters, returning a set without the specified type.
-
-
-
Method Detail
-
empty
public static CalculationParameters empty()
Obtains an empty instance with no parameters.- Returns:
- the empty instance
-
of
public static CalculationParameters of(CalculationParameter... parameters)
Obtains an instance from the specified parameters.The list will be converted to a
Map
usingCalculationParameter.queryType()
. Each parameter must refer to a different query type.If a parameter implements an interface that also extends
CalculationParameter
, that type will also be able to be searched for (unless it has been directly registered).- Parameters:
parameters
- the parameters- Returns:
- the calculation parameters
- Throws:
IllegalArgumentException
- if two parameters have same query type
-
of
public static CalculationParameters of(List<? extends CalculationParameter> parameters)
Obtains an instance from the specified parameters.The list will be converted to a
Map
usingCalculationParameter.queryType()
. Each parameter must refer to a different query type.If a parameter implements an interface that also extends
CalculationParameter
, that type will also be able to be searched for (unless it has been directly registered).- Parameters:
parameters
- the parameters- Returns:
- the calculation parameters
- Throws:
IllegalArgumentException
- if two parameters have same query type
-
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 trademeasure
- 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 CalculationParameter> Optional<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 forCalculationParameters
.- Returns:
- the meta-bean, not null
-
metaBean
public org.joda.beans.TypedMetaBean<CalculationParameters> metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getParameters
public ImmutableMap<Class<? extends CalculationParameter>,CalculationParameter> getParameters()
Gets the parameters, keyed by query type.- Returns:
- the value of the property, not null
-
-