Class MoneyExpressionVariable

  • All Implemented Interfaces:
    ExpressionVariable

    public class MoneyExpressionVariable
    extends Object
    implements ExpressionVariable
    Common, null-safe, operations for the MonetaryAmount fields.
    Author:
    Dima Myroniuk (dmyroniuk)
    • Constructor Detail

      • MoneyExpressionVariable

        public MoneyExpressionVariable()
    • Method Detail

      • toDouble

        public double toDouble​(@Nullable
                               javax.money.MonetaryAmount field)
        Returns the double value of the MonetaryAmount field. If field is null, returns Double.MIN_VALUE.
        Parameters:
        field - MonetaryAmount to convert to double.
        Returns:
        the double value of the MonetaryAmount field or Double.MIN_VALUE if null.
      • toDouble

        public double toDouble​(@Nullable
                               Map<String,​Object> objectMap)
        Converts the object map into a monetary amount and returns the double value of that amount. If the monetary amount cannot be resolved, returns Double.MIN_VALUE.
        Parameters:
        objectMap - the map of the monetary amount object to get the double value of
        Returns:
        the double value of the object map, or Double.MIN_VALUE if it cannot be resolved
      • toDouble

        public double toDouble​(@Nullable
                               javax.money.MonetaryAmount field,
                               double defaultValue)
        Returns the double value of the MonetaryAmount field. If field is null, returns defaultValue.
        Parameters:
        field - MonetaryAmount to convert to double.
        defaultValue - Value to default to if field is null
        Returns:
        the double value of the MonetaryAmount field or defaultValue if null.
      • fromMap

        @Nullable
        public javax.money.MonetaryAmount fromMap​(@Nullable
                                                  Map<String,​Object> objectMap)
        Resolves a monetary amount from an object map. This is necessary for cases when JSON has been deserialized as a simple map (i.e. Map<String, Object>), and a monetary amount needs to be retrieved from that object.
        Parameters:
        objectMap - the object map to convert the monetary amount from
        Returns:
        the monetary amount, or null if the required information is not present or correct