Enum ValueAdjustmentType

  • All Implemented Interfaces:
    Named, NamedEnum, Serializable, Comparable<ValueAdjustmentType>

    public enum ValueAdjustmentType
    extends 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 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​(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 name
        NullPointerException - if the argument is null
      • of

        public static ValueAdjustmentType 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
      • 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 String toString()
        Returns the formatted name of the type.
        Overrides:
        toString in class Enum<ValueAdjustmentType>
        Returns:
        the formatted string representing the type