Class ValueAdjustment
- java.lang.Object
-
- com.opengamma.strata.basics.value.ValueAdjustment
-
- All Implemented Interfaces:
Serializable,org.joda.beans.Bean,org.joda.beans.ImmutableBean
public final class ValueAdjustment extends Object implements org.joda.beans.ImmutableBean, Serializable
An adjustment to a value, describing how to change one value into another.A base value, represented as a
double, can be transformed into another value by specifying the result (absolute) or the calculation (relative).Type baseValue modifyingValue Calculation Replace 200 220 result = modifyingValue = 220DeltaAmount 200 20 result = baseValue + modifyingValue = (200 + 20) = 220DeltaMultiplier 200 0.1 result = baseValue + baseValue * modifyingValue = (200 + 200 * 0.1) = 220Multiplier 200 1.1 result = baseValue * modifyingValue = (200 * 1.1) = 220- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classValueAdjustment.MetaThe meta-bean forValueAdjustment.
-
Field Summary
Fields Modifier and Type Field Description static ValueAdjustmentNONEAn instance that makes no adjustment to the value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description doubleadjust(double baseValue)Adjusts the base value based on the criteria of this adjustment.booleanequals(Object obj)doublegetModifyingValue()Gets the value used to modify the base value.ValueAdjustmentTypegetType()Gets the type of adjustment to make.inthashCode()static ValueAdjustment.Metameta()The meta-bean forValueAdjustment.ValueAdjustment.MetametaBean()static ValueAdjustmentofDeltaAmount(double deltaAmount)Obtains an instance specifying an amount to add to the base value.static ValueAdjustmentofDeltaMultiplier(double deltaMultiplier)Obtains an instance specifying a multiplication factor, adding it to the base value.static ValueAdjustmentofMultiplier(double multiplier)Obtains an instance specifying a multiplication factor to apply to the base value.static ValueAdjustmentofReplace(double replacementValue)Obtains an instance that replaces the base value.StringtoString()
-
-
-
Field Detail
-
NONE
public static final ValueAdjustment NONE
An instance that makes no adjustment to the value.
-
-
Method Detail
-
ofReplace
public static ValueAdjustment ofReplace(double replacementValue)
Obtains an instance that replaces the base value.The base value is ignored when calculating the result.
- Parameters:
replacementValue- the replacement value to use as the result of the adjustment- Returns:
- the adjustment, capturing the replacement value
-
ofDeltaAmount
public static ValueAdjustment ofDeltaAmount(double deltaAmount)
Obtains an instance specifying an amount to add to the base value.The result will be
(baseValue + deltaAmount).- Parameters:
deltaAmount- the amount to be added to the base value- Returns:
- the adjustment, capturing the delta amount
-
ofDeltaMultiplier
public static ValueAdjustment ofDeltaMultiplier(double deltaMultiplier)
Obtains an instance specifying a multiplication factor, adding it to the base value.The result will be
(baseValue + baseValue * modifyingValue).- Parameters:
deltaMultiplier- the multiplication factor to apply to the base amount with the result added to the base amount- Returns:
- the adjustment, capturing the delta multiplier
-
ofMultiplier
public static ValueAdjustment ofMultiplier(double multiplier)
Obtains an instance specifying a multiplication factor to apply to the base value.The result will be
(baseValue * modifyingValue).- Parameters:
multiplier- the multiplication factor to apply to the base amount- Returns:
- the adjustment
-
adjust
public double adjust(double baseValue)
Adjusts the base value based on the criteria of this adjustment.For example, if this adjustment represents a 10% decrease, then the result will be the base value minus 10%.
- Parameters:
baseValue- the base, or previous, value to be adjusted- Returns:
- the calculated result
-
meta
public static ValueAdjustment.Meta meta()
The meta-bean forValueAdjustment.- Returns:
- the meta-bean, not null
-
metaBean
public ValueAdjustment.Meta metaBean()
- Specified by:
metaBeanin interfaceorg.joda.beans.Bean
-
getModifyingValue
public double getModifyingValue()
Gets the value used to modify the base value. This value is given meaning by the associated type.- Returns:
- the value of the property
-
getType
public ValueAdjustmentType getType()
Gets the type of adjustment to make.- Returns:
- the value of the property, not null
-
-