refactor non-fiat iso codes

This commit is contained in:
woodser 2023-05-23 17:39:26 -04:00
parent da0f4f4652
commit 1c172edb32

View File

@ -103,8 +103,7 @@ public class CurrencyUtil {
List<TraditionalCurrency> currencies = CountryUtil.getAllCountries().stream()
.map(country -> getCurrencyByCountryCode(country.code))
.collect(Collectors.toList());
currencies.add(new TraditionalCurrency(Currency.getInstance("XAG"))); // add silver
currencies.add(new TraditionalCurrency(Currency.getInstance("XAU"))); // add gold
for (String isoCode : nonFiatIsoCodes) currencies.add(new TraditionalCurrency(Currency.getInstance(isoCode)));
return currencies.stream().sorted(TradeCurrency::compareTo)
.distinct()
.collect(Collectors.toMap(TradeCurrency::getCode, Function.identity(), (x, y) -> x, LinkedHashMap::new));
@ -126,12 +125,13 @@ public class CurrencyUtil {
public static List<TraditionalCurrency> getMainTraditionalCurrencies() {
List<TraditionalCurrency> list = getMainFiatCurrencies();
list.add(new TraditionalCurrency("XAG"));
list.add(new TraditionalCurrency("XAU"));
for (String isoCode : nonFiatIsoCodes) list.add(new TraditionalCurrency(isoCode));
postProcessTraditionalCurrenciesList(list);
return list;
}
private static List<String> nonFiatIsoCodes = Arrays.asList("XAG", "XAU");
private static void postProcessTraditionalCurrenciesList(List<TraditionalCurrency> list) {
list.sort(TradeCurrency::compareTo);