Closed Thibstars closed 4 years ago
Has this method be found not relevant, or did you come across another way to do it?
Has this method be found not relevant, or did you come across another way to do it?
I might have been a bit fast requesting this feature, I have found another way to achieve my goal.
Here is my current approach (I can use any provider with this solution): `
ExchangeRateProvider rateProvider = MonetaryConversions.getExchangeRateProvider();
Collection<CurrencyUnit> currencies = Monetary.getCurrencies();
List<ExchangeRate> exchangeRates = currencies.stream()
.filter(currency -> rateProvider.isAvailable(DEFAULT_BASE_CURRENCY_CODE, currency.getCurrencyCode()))
.map(currency -> {
try {
return rateProvider.getExchangeRate(DEFAULT_BASE_CURRENCY_CODE, currency.getCurrencyCode());
} catch (Exception e) {
return null;
}
})
.filter(Objects::nonNull)
.sorted(Comparator.comparing(ExchangeRate::getFactor))
.collect(Collectors.toList());`
Add a method (
ExchangeRateProvider#getExchangeRates
) that returns a collection of all the exchange rates from an ExchangeRateProvider.Currently it is only possible to get an exchange rate of a specific currency.