public final class MutablePointSensitivities extends Object implements PointSensitivityBuilder
Contains a mutable list of point sensitivity objects, each referring to a specific point on a curve that was queried. The order of the list has no specific meaning, but does allow duplicates.
This is a mutable builder that is not intended for use in multiple threads.
It is intended to be used to create an immutable PointSensitivities instance.
Note that each individual point sensitivity implementation is immutable.
| Constructor and Description |
|---|
MutablePointSensitivities()
Creates an empty instance.
|
MutablePointSensitivities(List<? extends PointSensitivity> sensitivities)
Creates an instance with the specified sensitivities.
|
MutablePointSensitivities(PointSensitivity sensitivity)
Creates an instance with the specified sensitivity.
|
| Modifier and Type | Method and Description |
|---|---|
MutablePointSensitivities |
add(PointSensitivity sensitivity)
Adds a point sensitivity, mutating the internal list.
|
MutablePointSensitivities |
addAll(List<PointSensitivity> sensitivities)
Adds a list of point sensitivities, mutating the internal list.
|
MutablePointSensitivities |
addAll(MutablePointSensitivities other)
Merges the list of point sensitivities from another instance, mutating the internal list.
|
PointSensitivities |
build()
Builds the resulting point sensitivity.
|
MutablePointSensitivities |
buildInto(MutablePointSensitivities combination)
Builds the point sensitivity, adding to the specified mutable instance.
|
MutablePointSensitivities |
cloned()
Clones the point sensitivity builder.
|
MutablePointSensitivities |
combinedWith(PointSensitivityBuilder other)
Combines this sensitivity with another instance.
|
boolean |
equals(Object obj) |
ImmutableList<PointSensitivity> |
getSensitivities()
Gets the immutable list of point sensitivities.
|
int |
hashCode() |
MutablePointSensitivities |
mapSensitivity(DoubleUnaryOperator operator)
Returns an instance with the specified operation applied to the sensitivities in this builder.
|
MutablePointSensitivities |
multipliedBy(double factor)
Multiplies the sensitivities in this builder by the specified factor.
|
MutablePointSensitivities |
normalize()
Normalizes the point sensitivities by sorting and merging, mutating the internal list.
|
int |
size()
Gets the number of sensitivity entries.
|
MutablePointSensitivities |
sort()
Sorts the mutable list of point sensitivities.
|
PointSensitivities |
toImmutable()
Returns an immutable version of this object.
|
String |
toString() |
MutablePointSensitivities |
withCurrency(Currency currency)
Returns an instance with the specified currency applied to the sensitivities in this builder.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitnone, of, ofpublic MutablePointSensitivities()
public MutablePointSensitivities(PointSensitivity sensitivity)
sensitivity - the sensitivity to addpublic MutablePointSensitivities(List<? extends PointSensitivity> sensitivities)
sensitivities - the list of sensitivities, which is copiedpublic int size()
public ImmutableList<PointSensitivity> getSensitivities()
Each entry includes details of the curve it relates to.
public MutablePointSensitivities add(PointSensitivity sensitivity)
This instance will be mutated, with the new sensitivity added at the end of the list.
sensitivity - the sensitivity to addthis, for method chainingpublic MutablePointSensitivities addAll(List<PointSensitivity> sensitivities)
This instance will be mutated, with the new sensitivities added at the end of the list.
sensitivities - the sensitivities to addthis, for method chainingpublic MutablePointSensitivities addAll(MutablePointSensitivities other)
This instance will be mutated, with the new sensitivities added at the end of the list.
other - the other sensitivity to addthis, for method chainingpublic MutablePointSensitivities withCurrency(Currency currency)
PointSensitivityBuilderThe result will consists of the same points, but with the sensitivity currency assigned.
Builders may be mutable. Once this method is called, this instance must not be used. Instead, the result of the method must be used.
withCurrency in interface PointSensitivityBuildercurrency - the currency to be applied to the sensitivitiespublic MutablePointSensitivities multipliedBy(double factor)
PointSensitivityBuilderThe result will consist of the same points, but with each sensitivity multiplied.
Builders may be mutable. Once this method is called, this instance must not be used. Instead, the result of the method must be used.
multipliedBy in interface PointSensitivityBuilderfactor - the multiplicative factorpublic MutablePointSensitivities mapSensitivity(DoubleUnaryOperator operator)
PointSensitivityBuilderThe result will consist of the same points, but with the operator applied to each sensitivity.
This is used to apply a mathematical operation to the sensitivities. For example, the operator could multiply the sensitivities by a constant, or take the inverse.
inverse = base.mapSensitivities(value -> 1 / value);
Builders may be mutable. Once this method is called, this instance must not be used. Instead, the result of the method must be used.
mapSensitivity in interface PointSensitivityBuilderoperator - the operator to be applied to the sensitivitiespublic MutablePointSensitivities combinedWith(PointSensitivityBuilder other)
PointSensitivityBuilderThis returns an instance with a combined list of point sensitivities.
Builders may be mutable. Once this method is called, this instance must not be used. Instead, the result of the method must be used.
combinedWith in interface PointSensitivityBuilderother - the other sensitivity builderpublic MutablePointSensitivities buildInto(MutablePointSensitivities combination)
PointSensitivityBuilderbuildInto in interface PointSensitivityBuildercombination - the combination object to add topublic PointSensitivities build()
PointSensitivityBuilder
This returns a PointSensitivities instance.
Builders may be mutable. Once this method is called, this instance must not be used.
build in interface PointSensitivityBuilderpublic MutablePointSensitivities cloned()
PointSensitivityBuilder
This returns a PointSensitivityBuilder instance that is independent
from the original. Immutable implementations may return themselves.
Builders may be mutable. Using this method allows a copy of the original to be obtained, so both the original and the clone can be used.
cloned in interface PointSensitivityBuilderpublic MutablePointSensitivities sort()
Sorts the point sensitivities in this instance.
this, for method chainingpublic MutablePointSensitivities normalize()
The list of sensitivities is sorted and then merged. Any two entries that represent the same curve query are merged. For example, if there are two point sensitivities that were created based on the same curve, currency and fixing date, then the entries are combined, summing the sensitivity value.
The intention is that normalization occurs after gathering all the point sensitivities.
normalize in interface PointSensitivityBuilderthis, for method chainingpublic PointSensitivities toImmutable()
The result is an instance of the immutable PointSensitivities.
It will contain the same individual point sensitivities.
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.