Class ParameterizedDataCombiner
- java.lang.Object
-
- com.opengamma.strata.market.param.ParameterizedDataCombiner
-
public final class ParameterizedDataCombiner extends Object
Helper that can be used to combine two or more underlying instances ofParameterizedData
.This is used by implementations of
ParameterizedData
that are based on more than one underlyingParameterizedData
instance.This helper should be created in the constructor of the combined instance. In each of the five
ParameterizedData
methods of the combined instance, this helper should be invoked. SeeDiscountFxForwardRates
for sample usage.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getParameter(int parameterIndex)
Gets the value of the parameter at the specified index.int
getParameterCount()
Gets the number of parameters.ParameterMetadata
getParameterMetadata(int parameterIndex)
Gets the metadata of the parameter at the specified index.static ParameterizedDataCombiner
of(ParameterizedData... instances)
Obtains an instance that can combine the specified underlying instances.static ParameterizedDataCombiner
of(List<? extends ParameterizedData> instances)
Obtains an instance that can combine the specified underlying instances.<R extends ParameterizedData>
RunderlyingWithParameter(int underlyingIndex, Class<R> underlyingType, int parameterIndex, double newValue)
Updates a parameter on the specified underlying.<R extends ParameterizedData>
RunderlyingWithPerturbation(int underlyingIndex, Class<R> underlyingType, ParameterPerturbation perturbation)
Applies a perturbation to the specified underlying.<R extends ParameterizedData>
List<R>withParameter(Class<R> underlyingType, int parameterIndex, double newValue)
Updates a parameter on the specified list of underlying instances.<R extends ParameterizedData>
List<R>withPerturbation(Class<R> underlyingType, ParameterPerturbation perturbation)
Applies a perturbation to each underlying.
-
-
-
Method Detail
-
of
public static ParameterizedDataCombiner of(ParameterizedData... instances)
Obtains an instance that can combine the specified underlying instances.- Parameters:
instances
- the underlying instances to combine- Returns:
- the combiner
-
of
public static ParameterizedDataCombiner of(List<? extends ParameterizedData> instances)
Obtains an instance that can combine the specified underlying instances.- Parameters:
instances
- the underlying instances to combine- Returns:
- the combiner
-
getParameterCount
public int getParameterCount()
Gets the number of parameters.This returns the total parameter count of all the instances.
- Returns:
- the number of parameters
-
getParameter
public double getParameter(int parameterIndex)
Gets the value of the parameter at the specified index.This gets the parameter from the correct instance.
- Parameters:
parameterIndex
- the zero-based index of the parameter to get- Returns:
- the value of the parameter
- Throws:
IndexOutOfBoundsException
- if the index is invalid
-
getParameterMetadata
public ParameterMetadata getParameterMetadata(int parameterIndex)
Gets the metadata of the parameter at the specified index.This gets the parameter metadata from the correct instance.
- Parameters:
parameterIndex
- the zero-based index of the parameter to get- Returns:
- the metadata of the parameter
- Throws:
IndexOutOfBoundsException
- if the index is invalid
-
underlyingWithParameter
public <R extends ParameterizedData> R underlyingWithParameter(int underlyingIndex, Class<R> underlyingType, int parameterIndex, double newValue)
Updates a parameter on the specified underlying.This should be invoked once for each of the underlying instances. It is intended to be used to pass the result of each invocation to the constructor of the combined instance.
If the parameter index applies to the underlying, it is updated. If the parameter index does not apply to the underlying, no error occurs.
- Type Parameters:
R
- the type of the underlying- Parameters:
underlyingIndex
- the index of the underlying instanceunderlyingType
- the type of the parameterized data at the specified indexparameterIndex
- the zero-based index of the parameter to changenewValue
- the new value for the specified parameter- Returns:
- a parameterized data instance based on this with the specified parameter altered
- Throws:
IndexOutOfBoundsException
- if the index is invalid
-
underlyingWithPerturbation
public <R extends ParameterizedData> R underlyingWithPerturbation(int underlyingIndex, Class<R> underlyingType, ParameterPerturbation perturbation)
Applies a perturbation to the specified underlying.This should be invoked once for each of the underlying instances. It is intended to be used to pass the result of each invocation to the constructor of the combined instance.
- Type Parameters:
R
- the type of the underlying- Parameters:
underlyingIndex
- the index of the underlying instanceunderlyingType
- the type of the parameterized data at the specified indexperturbation
- the perturbation to apply- Returns:
- a parameterized data instance based on this with the specified perturbation applied
-
withParameter
public <R extends ParameterizedData> List<R> withParameter(Class<R> underlyingType, int parameterIndex, double newValue)
Updates a parameter on the specified list of underlying instances.The correct underlying is identified and updated, with the list returned.
- Type Parameters:
R
- the type of the underlying- Parameters:
underlyingType
- the type of the parameterized data at the specified indexparameterIndex
- the zero-based index of the parameter to changenewValue
- the new value for the specified parameter- Returns:
- a parameterized data instance based on this with the specified parameter altered
- Throws:
IndexOutOfBoundsException
- if the index is invalid
-
withPerturbation
public <R extends ParameterizedData> List<R> withPerturbation(Class<R> underlyingType, ParameterPerturbation perturbation)
Applies a perturbation to each underlying.The updated list of underlying instances is returned.
- Type Parameters:
R
- the type of the underlying- Parameters:
underlyingType
- the type of the parameterized data at the specified indexperturbation
- the perturbation to apply- Returns:
- a parameterized data instance based on this with the specified parameter altered
- Throws:
IndexOutOfBoundsException
- if the index is invalid
-
-