Class CurrentCurrencyUtils
java.lang.Object
com.broadleafcommerce.data.tracking.core.mapping.money.CurrentCurrencyUtils
Untility to allow for resolving the currency based on a supplied object and / or the
ContextInfo
.- Author:
- Kelly Tisdell (ktisdell)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic javax.money.CurrencyUnit
resolveCurrentCurrency
(ContextInfo contextInfo) Returns theCurrencyUnit
that matches theContextInfo.getDefaultCurrency()
.static javax.money.CurrencyUnit
resolveCurrentCurrency
(Object currencySupplier, ContextInfo contextInfo) Returns theCurrencyUnit
that most closely matches the parameters provided.
-
Constructor Details
-
CurrentCurrencyUtils
public CurrentCurrencyUtils()
-
-
Method Details
-
resolveCurrentCurrency
@NonNull public static javax.money.CurrencyUnit resolveCurrentCurrency(@Nullable ContextInfo contextInfo) Returns theCurrencyUnit
that matches theContextInfo.getDefaultCurrency()
. If theContextInfo
is null, orContextInfo.getDefaultCurrency()
is null, then this returns the default system currency fromMonetaryUtils.defaultCurrency()
.- Parameters:
contextInfo
-- Returns:
- See Also:
-
resolveCurrentCurrency
@NonNull public static javax.money.CurrencyUnit resolveCurrentCurrency(@Nullable Object currencySupplier, @Nullable ContextInfo contextInfo) Returns theCurrencyUnit
that most closely matches the parameters provided. First, if the currencySupplier is not null and is an instance ofCurrencySupplier
thenCurrencySupplier.getCurrency()
will be called. If the currencySupplier argument is null or is not an instance ofCurrencySupplier
or contains a null currency, then theContextInfo
will be queried. If theContextInfo
is not null, andContextInfo.getDefaultCurrency()
is not null, then that is what will be returned. Finally, if no currency could be resolved from the currencySupplier argument or the contextInfo argument, then the default system currency will be used, resolved fromMonetaryUtils.defaultCurrency()
.- Parameters:
currencySupplier
-contextInfo
-- Returns:
- See Also:
-