Class DefaultCurrencyAmountResolutionStrategy
- java.lang.Object
-
- de.hybris.platform.promotionengineservices.promotionengine.impl.DefaultCurrencyAmountResolutionStrategy
-
- All Implemented Interfaces:
PromotionMessageParameterResolutionStrategy
public class DefaultCurrencyAmountResolutionStrategy extends java.lang.Object implements PromotionMessageParameterResolutionStrategy
DefaultCurrencyAmountResolutionStrategy resolves the givenRuleParameterData.getValue()attribute into a formatted currency amount, for example $200.00. The value attribute is cast into aMap<String,BigDecimal>and the givenPromotionResultModel.getOrder()'s currency isocode is used as key to lookup the amount to be formatted.
-
-
Constructor Summary
Constructors Constructor Description DefaultCurrencyAmountResolutionStrategy()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.text.DecimalFormatadjustDigits(java.text.DecimalFormat format, CurrencyModel currency)AdjustsDecimalFormat's fraction digits according to givenCurrencyModel.protected static java.text.DecimalFormatadjustSymbol(java.text.DecimalFormat format, CurrencyModel currency)AdjustsDecimalFormat's symbol according to givenCurrencyModel.protected java.lang.StringformatCurrencyAmount(java.util.Locale locale, CurrencyModel currency, java.math.BigDecimal amount)Format an amount in a currency for a locale.protected PromotionResultUtilsgetPromotionResultUtils()RuleParameterDatagetReplacedParameter(RuleParameterData paramToReplace, PromotionResultModel promotionResult, java.lang.Object actualValueAsObject)returnsRuleParameterDatacreated from givenRuleParameterDatawith replaced actual value.java.lang.StringgetValue(RuleParameterData data, PromotionResultModel promotionResult, java.util.Locale locale)resolves the givenRuleParameterDatainto a displayable Object.voidsetPromotionResultUtils(PromotionResultUtils promotionResultUtils)
-
-
-
Method Detail
-
getValue
public java.lang.String getValue(RuleParameterData data, PromotionResultModel promotionResult, java.util.Locale locale)
Description copied from interface:PromotionMessageParameterResolutionStrategyresolves the givenRuleParameterDatainto a displayable Object.- Specified by:
getValuein interfacePromotionMessageParameterResolutionStrategy- Parameters:
data- the rule parameter to resolvepromotionResult- the promotion resultlocale- the locale- Returns:
- an object (to be displayed via
#toString() - Throws:
java.lang.IllegalArgumentException- if any of the given parameters is nulljava.lang.ClassCastException- if the given data.getValue() doesn't contain a Map
-
getReplacedParameter
public RuleParameterData getReplacedParameter(RuleParameterData paramToReplace, PromotionResultModel promotionResult, java.lang.Object actualValueAsObject)
Description copied from interface:PromotionMessageParameterResolutionStrategyreturnsRuleParameterDatacreated from givenRuleParameterDatawith replaced actual value.- Specified by:
getReplacedParameterin interfacePromotionMessageParameterResolutionStrategy- Parameters:
paramToReplace- original rule parameterpromotionResult- the promotion resultactualValueAsObject- actual value to set- Returns:
- an object (to be displayed via
#toString()
-
formatCurrencyAmount
protected java.lang.String formatCurrencyAmount(java.util.Locale locale, CurrencyModel currency, java.math.BigDecimal amount)Format an amount in a currency for a locale.- Parameters:
locale- the java locale that the amount should be rendered incurrency- the hybris currency model for the amountamount- the value- Returns:
- a formatted string
-
adjustDigits
protected java.text.DecimalFormat adjustDigits(java.text.DecimalFormat format, CurrencyModel currency)AdjustsDecimalFormat's fraction digits according to givenCurrencyModel.
-
adjustSymbol
protected static java.text.DecimalFormat adjustSymbol(java.text.DecimalFormat format, CurrencyModel currency)AdjustsDecimalFormat's symbol according to givenCurrencyModel.
-
getPromotionResultUtils
protected PromotionResultUtils getPromotionResultUtils()
-
setPromotionResultUtils
public void setPromotionResultUtils(PromotionResultUtils promotionResultUtils)
-
-