public class CurrentCurrencyUtils extends Object
ContextInfo
.Constructor and Description |
---|
CurrentCurrencyUtils() |
Modifier and Type | Method and Description |
---|---|
static javax.money.CurrencyUnit |
resolveCurrentCurrency(ContextInfo contextInfo)
Returns the
CurrencyUnit that matches the ContextInfo.getDefaultCurrency() . |
static javax.money.CurrencyUnit |
resolveCurrentCurrency(Object currencySupplier,
ContextInfo contextInfo)
Returns the
CurrencyUnit that most closely matches the parameters provided. |
@NonNull public static javax.money.CurrencyUnit resolveCurrentCurrency(@Nullable ContextInfo contextInfo)
CurrencyUnit
that matches the ContextInfo.getDefaultCurrency()
.
If the ContextInfo
is null, or ContextInfo.getDefaultCurrency()
is null, then
this returns the default system currency from MonetaryUtils.defaultCurrency()
.contextInfo
- ContextInfoCustomizer
@NonNull public static javax.money.CurrencyUnit resolveCurrentCurrency(@Nullable Object currencySupplier, @Nullable ContextInfo contextInfo)
CurrencyUnit
that most closely matches the parameters provided. First, if
the currencySupplier is not null and is an instance of CurrencySupplier
then
CurrencySupplier.getCurrency()
will be called. If the currencySupplier argument is
null or is not an instance of CurrencySupplier
or contains a null currency, then the
ContextInfo
will be queried. If the ContextInfo
is not null, and
ContextInfo.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 from
MonetaryUtils.defaultCurrency()
.currencySupplier
- contextInfo
- ContextInfoCustomizer
Copyright © 2021. All rights reserved.