Map ETHC to ETH

This commit is contained in:
Manfred Karrer 2016-07-26 01:23:46 +02:00
parent aa8f146dca
commit 21d8c82eb3

View File

@ -190,6 +190,9 @@ public class CurrencyUtil {
}
public static boolean isFiatCurrency(String currencyCode) {
//TODO remove after ETHC is not used anymore
currencyCode = map_ETHC_to_ETC(currencyCode);
try {
return currencyCode != null && !currencyCode.isEmpty() && !isCryptoCurrency(currencyCode) && Currency.getInstance(currencyCode) != null;
} catch (Throwable t) {
@ -198,19 +201,31 @@ public class CurrencyUtil {
}
public static Optional<FiatCurrency> getFiatCurrency(String currencyCode) {
return allSortedFiatCurrencies.stream().filter(e -> e.getCode().equals(currencyCode)).findAny();
//TODO remove after ETHC is not used anymore
final String finalCurrencyCode = map_ETHC_to_ETC(currencyCode);
return allSortedFiatCurrencies.stream().filter(e -> e.getCode().equals(finalCurrencyCode)).findAny();
}
@SuppressWarnings("WeakerAccess")
public static boolean isCryptoCurrency(String currencyCode) {
//TODO remove after ETHC is not used anymore
currencyCode = map_ETHC_to_ETC(currencyCode);
return getCryptoCurrency(currencyCode).isPresent();
}
public static Optional<CryptoCurrency> getCryptoCurrency(String currencyCode) {
return getAllSortedCryptoCurrencies().stream().filter(e -> e.getCode().equals(currencyCode)).findAny();
//TODO remove after ETHC is not used anymore
final String finalCurrencyCode = map_ETHC_to_ETC(currencyCode);
return getAllSortedCryptoCurrencies().stream().filter(e -> e.getCode().equals(finalCurrencyCode)).findAny();
}
public static Optional<TradeCurrency> getTradeCurrency(String currencyCode) {
//TODO remove after ETHC is not used anymore
currencyCode = map_ETHC_to_ETC(currencyCode);
Optional<FiatCurrency> fiatCurrencyOptional = getFiatCurrency(currencyCode);
if (isFiatCurrency(currencyCode) && fiatCurrencyOptional.isPresent()) {
return Optional.of(fiatCurrencyOptional.get());
@ -230,6 +245,9 @@ public class CurrencyUtil {
public static String getNameByCode(String currencyCode) {
//TODO remove after ETHC is not used anymore
currencyCode = map_ETHC_to_ETC(currencyCode);
if (isCryptoCurrency(currencyCode))
return getCryptoCurrency(currencyCode).get().getName();
else
@ -241,6 +259,14 @@ public class CurrencyUtil {
}
}
public static String map_ETHC_to_ETC(String currencyCode) {
//TODO remove after ETHC is not used anymore
if (currencyCode.equals("ETHC"))
return "ETC";
else
return currencyCode;
}
public static TradeCurrency getDefaultTradeCurrency() {
return Preferences.getDefaultTradeCurrency();
}