Enum ShiftType

  • All Implemented Interfaces:
    Named, NamedEnum, java.io.Serializable, java.lang.Comparable<ShiftType>

    public enum ShiftType
    extends java.lang.Enum<ShiftType>
    implements NamedEnum
    Enum representing alternative ways to apply a shift which modifies the value of a piece of market data.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      ABSOLUTE
      An absolute shift where the shift amount is added to the value.
      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.
    • 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​(java.lang.String name)
      Obtains an instance from the specified name.
      java.lang.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​(java.lang.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.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface com.opengamma.strata.collect.named.NamedEnum

        getName
    • 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 nonzero value.

      • 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 nonzero value.

    • 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​(java.lang.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:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • of

        public static ShiftType of​(java.lang.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:
        java.lang.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 shift
        shiftAmount - 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 value
        shiftedValue - the shifted value
        Returns:
        the shift amount
      • toString

        public java.lang.String toString()
        Returns the formatted name of the type.
        Overrides:
        toString in class java.lang.Enum<ShiftType>
        Returns:
        the formatted string representing the type