Class DefaultCurrencyAmountResolutionStrategy
java.lang.Object
de.hybris.platform.promotionengineservices.promotionengine.impl.DefaultCurrencyAmountResolutionStrategy
- All Implemented Interfaces:
PromotionMessageParameterResolutionStrategy
public class DefaultCurrencyAmountResolutionStrategy
extends Object
implements PromotionMessageParameterResolutionStrategy
DefaultCurrencyAmountResolutionStrategy resolves the given
RuleParameterData.getValue() attribute into a
formatted currency amount, for example $200.00. The value attribute is cast into a Map<String,BigDecimal> and
the given PromotionResultModel.getOrder()'s currency isocode is used as key to lookup the amount to be
formatted.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected DecimalFormatadjustDigits(DecimalFormat format, CurrencyModel currency) AdjustsDecimalFormat's fraction digits according to givenCurrencyModel.protected static DecimalFormatadjustSymbol(DecimalFormat format, CurrencyModel currency) AdjustsDecimalFormat's symbol according to givenCurrencyModel.protected StringformatCurrencyAmount(Locale locale, CurrencyModel currency, BigDecimal amount) Format an amount in a currency for a locale.protected PromotionResultUtilsgetReplacedParameter(RuleParameterData paramToReplace, PromotionResultModel promotionResult, Object actualValueAsObject) returnsRuleParameterDatacreated from givenRuleParameterDatawith replaced actual value.getValue(RuleParameterData data, PromotionResultModel promotionResult, Locale locale) resolves the givenRuleParameterDatainto a displayable Object.voidsetPromotionResultUtils(PromotionResultUtils promotionResultUtils)
-
Constructor Details
-
DefaultCurrencyAmountResolutionStrategy
public DefaultCurrencyAmountResolutionStrategy()
-
-
Method Details
-
getValue
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:
IllegalArgumentException- if any of the given parameters is nullClassCastException- if the given data.getValue() doesn't contain a Map<String,BigDecimal>
-
getReplacedParameter
public RuleParameterData getReplacedParameter(RuleParameterData paramToReplace, PromotionResultModel promotionResult, 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
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
AdjustsDecimalFormat's fraction digits according to givenCurrencyModel. -
adjustSymbol
AdjustsDecimalFormat's symbol according to givenCurrencyModel. -
getPromotionResultUtils
-
setPromotionResultUtils
-