Enum ValueAdjustmentType

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

    public enum ValueAdjustmentType
    extends java.lang.Enum<ValueAdjustmentType>
    implements NamedEnum
    The type of value adjustment.

    A double value can be transformed into another value in various different ways. Each type is a function of two values, the base value and the modifying value.

    Each type represents a different way to express the same concept. For example, here is how an increase from 200 to 220 could be represented:

    TypebaseValuemodifyingValueCalculation
    Replace200220result = modifyingValue = 220
    DeltaAmount20020result = baseValue + modifyingValue = (200 + 20) = 220
    DeltaMultiplier2000.1 result = baseValue + baseValue * modifyingValue = (200 + 200 * 0.1) = 220
    Multiplier2001.1result = baseValue * modifyingValue = (200 * 1.1) = 220
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      DELTA_AMOUNT
      Calculates the result by treating the modifying value as a delta, adding it to the base value.
      DELTA_MULTIPLIER
      Calculates the result by treating the modifying value as a multiplication factor, adding it to the base value.
      MULTIPLIER
      Calculates the result by treating the modifying value as a multiplication factor to apply to the base value.
      REPLACE
      The modifying value replaces the base value.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract double adjust​(double baseValue, double modifyingValue)
      Adjusts the base value based on the type and the modifying value.
      static ValueAdjustmentType of​(java.lang.String name)
      Obtains an instance from the specified name.
      java.lang.String toString()
      Returns the formatted name of the type.
      static ValueAdjustmentType valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static ValueAdjustmentType[] 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

      • REPLACE

        public static final ValueAdjustmentType REPLACE
        The modifying value replaces the base value. The input base value is ignored.

        The result is modifyingValue.

      • DELTA_AMOUNT

        public static final ValueAdjustmentType DELTA_AMOUNT
        Calculates the result by treating the modifying value as a delta, adding it to the base value.

        The result is (baseValue + modifyingValue).

        This adjustment type can be referred to as an absolute shift.

      • DELTA_MULTIPLIER

        public static final ValueAdjustmentType DELTA_MULTIPLIER
        Calculates the result by treating the modifying value as a multiplication factor, adding it to the base value.

        The result is (baseValue + baseValue * modifyingValue).

        This adjustment type can be referred to as a relative shift.

      • MULTIPLIER

        public static final ValueAdjustmentType MULTIPLIER
        Calculates the result by treating the modifying value as a multiplication factor to apply to the base value.

        The result is (baseValue * modifyingValue).

    • Method Detail

      • values

        public static ValueAdjustmentType[] 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 (ValueAdjustmentType c : ValueAdjustmentType.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static ValueAdjustmentType 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 ValueAdjustmentType 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
      • adjust

        public abstract double adjust​(double baseValue,
                                      double modifyingValue)
        Adjusts the base value based on the type and the modifying value.
        Parameters:
        baseValue - the base, or previous, value to be adjusted
        modifyingValue - the value that the type uses to modify the base value
        Returns:
        the calculated result
      • toString

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