Class MoneyExpressionVariable
java.lang.Object
com.broadleafcommerce.rulesengine.expression.util.MoneyExpressionVariable
- All Implemented Interfaces:
ExpressionVariable
Common, null-safe, operations for the
MonetaryAmount fields.- Author:
- Dima Myroniuk (dmyroniuk)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjavax.money.MonetaryAmountResolves a monetary amount from an object map.getName()doubleConverts the object map into a monetary amount and returns the double value of that amount.doubletoDouble(javax.money.MonetaryAmount field) Returns the double value of theMonetaryAmountfield.doubletoDouble(javax.money.MonetaryAmount field, double defaultValue) Returns the double value of theMonetaryAmountfield.
-
Field Details
-
NAME
- See Also:
-
-
Constructor Details
-
MoneyExpressionVariable
public MoneyExpressionVariable()
-
-
Method Details
-
getName
- Specified by:
getNamein interfaceExpressionVariable- Returns:
- Name of the variable, must not be null
-
toDouble
public double toDouble(@Nullable javax.money.MonetaryAmount field) - Parameters:
field- MonetaryAmount to convert to double.- Returns:
- the double value of the
MonetaryAmountfield orDouble.MIN_VALUEif null.
-
toDouble
Converts the object map into a monetary amount and returns the double value of that amount. If the monetary amount cannot be resolved, returnsDouble.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_VALUEif it cannot be resolved
-
toDouble
public double toDouble(@Nullable javax.money.MonetaryAmount field, double defaultValue) Returns the double value of theMonetaryAmountfield. Iffieldis null, returnsdefaultValue.- Parameters:
field- MonetaryAmount to convert to double.defaultValue- Value to default to iffieldis null- Returns:
- the double value of the
MonetaryAmountfield ordefaultValueif null.
-
fromMap
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
-