Package com.opengamma.strata.market
Enum ShiftType
- java.lang.Object
-
- java.lang.Enum<ShiftType>
-
- com.opengamma.strata.market.ShiftType
-
- All Implemented Interfaces:
Named
,NamedEnum
,Serializable
,Comparable<ShiftType>
public enum ShiftType extends Enum<ShiftType> implements NamedEnum
Enum representing alternative ways to apply a shift which modifies the value of a piece of market data.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Enum Constant Detail
-
RELATIVE
public static final ShiftType RELATIVE
A relative shift where the value is scaled by the shift amount.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 nonzerovalue
.
-
ABSOLUTE
public static final ShiftType ABSOLUTE
An absolute shift where the shift amount is added to the value.shiftedValue = (value + shiftAmount)
-
SCALED
public static final ShiftType SCALED
A scaled shift where the value is multiplied by the shift.shiftedValue = (value * shiftAmount)
shiftAmount
is well-defined for nonzerovalue
.
-
-
Method Detail
-
values
public static ShiftType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (ShiftType c : ShiftType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ShiftType valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
of
public static ShiftType of(String name)
Obtains an instance from the specified name.Parsing handles the mixed case form produced by
toString()
and the upper and lower case variants of the enum constant name.- Parameters:
name
- the name to parse- Returns:
- the type
- Throws:
IllegalArgumentException
- if the name is not known
-
applyShift
public abstract double applyShift(double value, double shiftAmount)
Applies the shift to the value using appropriate logic for the shift type.- Parameters:
value
- the value to shiftshiftAmount
- the shift to apply- Returns:
- the shifted value
-
toValueAdjustment
public abstract ValueAdjustment toValueAdjustment(double shiftAmount)
Returns a value adjustment that applies the shift amount using appropriate logic for the shift type.- Parameters:
shiftAmount
- the shift to apply- Returns:
- a value adjustment that applies the shift amount using appropriate logic for the shift type
-
computeShift
public abstract double computeShift(double baseValue, double shiftedValue)
Computes the shift amount using appropriate logic for the shift type.- Parameters:
baseValue
- the base valueshiftedValue
- the shifted value- Returns:
- the shift amount
-
-