Class ValueAdjustment

  • All Implemented Interfaces:
    Serializable, org.joda.beans.Bean, org.joda.beans.ImmutableBean

    public final class ValueAdjustment
    extends Object
    implements org.joda.beans.ImmutableBean, Serializable
    An adjustment to a value, describing how to change one value into another.

    A base value, represented as a double, can be transformed into another value by specifying the result (absolute) or the calculation (relative).

    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
    See Also:
    Serialized Form
    • Field Detail

      • NONE

        public static final ValueAdjustment NONE
        An instance that makes no adjustment to the value.
    • Method Detail

      • ofReplace

        public static ValueAdjustment ofReplace​(double replacementValue)
        Obtains an instance that replaces the base value.

        The base value is ignored when calculating the result.

        Parameters:
        replacementValue - the replacement value to use as the result of the adjustment
        Returns:
        the adjustment, capturing the replacement value
      • ofDeltaAmount

        public static ValueAdjustment ofDeltaAmount​(double deltaAmount)
        Obtains an instance specifying an amount to add to the base value.

        The result will be (baseValue + deltaAmount).

        Parameters:
        deltaAmount - the amount to be added to the base value
        Returns:
        the adjustment, capturing the delta amount
      • ofDeltaMultiplier

        public static ValueAdjustment ofDeltaMultiplier​(double deltaMultiplier)
        Obtains an instance specifying a multiplication factor, adding it to the base value.

        The result will be (baseValue + baseValue * modifyingValue).

        Parameters:
        deltaMultiplier - the multiplication factor to apply to the base amount with the result added to the base amount
        Returns:
        the adjustment, capturing the delta multiplier
      • ofMultiplier

        public static ValueAdjustment ofMultiplier​(double multiplier)
        Obtains an instance specifying a multiplication factor to apply to the base value.

        The result will be (baseValue * modifyingValue).

        Parameters:
        multiplier - the multiplication factor to apply to the base amount
        Returns:
        the adjustment
      • adjust

        public double adjust​(double baseValue)
        Adjusts the base value based on the criteria of this adjustment.

        For example, if this adjustment represents a 10% decrease, then the result will be the base value minus 10%.

        Parameters:
        baseValue - the base, or previous, value to be adjusted
        Returns:
        the calculated result
      • meta

        public static ValueAdjustment.Meta meta()
        The meta-bean for ValueAdjustment.
        Returns:
        the meta-bean, not null
      • metaBean

        public ValueAdjustment.Meta metaBean()
        Specified by:
        metaBean in interface org.joda.beans.Bean
      • getModifyingValue

        public double getModifyingValue()
        Gets the value used to modify the base value. This value is given meaning by the associated type.
        Returns:
        the value of the property
      • getType

        public ValueAdjustmentType getType()
        Gets the type of adjustment to make.
        Returns:
        the value of the property, not null
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object