public enum ShiftType extends Enum<ShiftType> implements NamedEnum
| Enum Constant and Description |
|---|
ABSOLUTE
An absolute shift where the shift amount is added to the value.
|
FIXED
A fixed shift where the value becomes the shift amount.
|
RELATIVE
A relative shift where the value is scaled by the shift amount.
|
SCALED
A scaled shift where the value is multiplied by the shift.
|
| Modifier and Type | Method and Description |
|---|---|
abstract double |
applyShift(double value,
double shiftAmount)
Applies the shift to the value using appropriate logic for the shift type.
|
abstract double |
computeShift(double baseValue,
double shiftedValue)
Computes the shift amount using appropriate logic for the shift type.
|
static ShiftType |
of(String name)
Obtains an instance from the specified name.
|
String |
toString()
Returns the formatted name of the type.
|
abstract ValueAdjustment |
toValueAdjustment(double shiftAmount)
Returns a value adjustment that applies the shift amount using appropriate logic for the shift type.
|
static ShiftType |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static ShiftType[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ShiftType RELATIVE
The shift amount is interpreted as a decimal percentage. For example, a shift amount of 0.1 is a shift of +10% which multiplies the value by 1.1. A shift amount of -0.2 is a shift of -20% which multiplies the value by 0.8.
shiftedValue = (value + value * shiftAmount)
shiftAmount is well-defined for nonzero value.
public static final ShiftType ABSOLUTE
shiftedValue = (value + shiftAmount)
public static final ShiftType SCALED
shiftedValue = (value * shiftAmount)
shiftAmount is well-defined for nonzero value.
public static final ShiftType FIXED
shiftedValue = shiftAmount
public static ShiftType[] values()
for (ShiftType c : ShiftType.values()) System.out.println(c);
public static ShiftType valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic static ShiftType of(String name)
Parsing handles the mixed case form produced by toString() and
the upper and lower case variants of the enum constant name.
name - the name to parseIllegalArgumentException - if the name is not knownpublic abstract double applyShift(double value,
double shiftAmount)
value - the value to shiftshiftAmount - the shift to applypublic abstract ValueAdjustment toValueAdjustment(double shiftAmount)
shiftAmount - the shift to applypublic abstract double computeShift(double baseValue,
double shiftedValue)
baseValue - the base valueshiftedValue - the shifted valueCopyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.