public final class ParameterizedDataCombiner extends Object
ParameterizedData.
This is used by implementations of ParameterizedData that are based on more
than one underlying ParameterizedData 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. See DiscountFxForwardRates for sample usage.
| Modifier and Type | Method and 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(List<? extends ParameterizedData> instances)
Obtains an instance that can combine the specified underlying instances.
|
static ParameterizedDataCombiner |
of(ParameterizedData... instances)
Obtains an instance that can combine the specified underlying instances.
|
<R extends ParameterizedData> |
underlyingWithParameter(int underlyingIndex,
Class<R> underlyingType,
int parameterIndex,
double newValue)
Updates a parameter on the specified underlying.
|
<R extends ParameterizedData> |
underlyingWithPerturbation(int underlyingIndex,
Class<R> underlyingType,
ParameterPerturbation perturbation)
Applies a perturbation to the specified underlying.
|
<R extends ParameterizedData> |
withParameter(Class<R> underlyingType,
int parameterIndex,
double newValue)
Updates a parameter on the specified list of underlying instances.
|
<R extends ParameterizedData> |
withPerturbation(Class<R> underlyingType,
ParameterPerturbation perturbation)
Applies a perturbation to each underlying.
|
public static ParameterizedDataCombiner of(ParameterizedData... instances)
instances - the underlying instances to combinepublic static ParameterizedDataCombiner of(List<? extends ParameterizedData> instances)
instances - the underlying instances to combinepublic int getParameterCount()
This returns the total parameter count of all the instances.
public double getParameter(int parameterIndex)
This gets the parameter from the correct instance.
parameterIndex - the zero-based index of the parameter to getIndexOutOfBoundsException - if the index is invalidpublic ParameterMetadata getParameterMetadata(int parameterIndex)
This gets the parameter metadata from the correct instance.
parameterIndex - the zero-based index of the parameter to getIndexOutOfBoundsException - if the index is invalidpublic <R extends ParameterizedData> R underlyingWithParameter(int underlyingIndex, Class<R> underlyingType, int parameterIndex, double newValue)
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.
R - the type of the underlyingunderlyingIndex - 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 parameterIndexOutOfBoundsException - if the index is invalidpublic <R extends ParameterizedData> R underlyingWithPerturbation(int underlyingIndex, Class<R> underlyingType, ParameterPerturbation perturbation)
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.
R - the type of the underlyingunderlyingIndex - the index of the underlying instanceunderlyingType - the type of the parameterized data at the specified indexperturbation - the perturbation to applypublic <R extends ParameterizedData> List<R> withParameter(Class<R> underlyingType, int parameterIndex, double newValue)
The correct underlying is identified and updated, with the list returned.
R - the type of the underlyingunderlyingType - 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 parameterIndexOutOfBoundsException - if the index is invalidpublic <R extends ParameterizedData> List<R> withPerturbation(Class<R> underlyingType, ParameterPerturbation perturbation)
The updated list of underlying instances is returned.
R - the type of the underlyingunderlyingType - the type of the parameterized data at the specified indexperturbation - the perturbation to applyIndexOutOfBoundsException - if the index is invalidCopyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.