Skip to content

Commit

Permalink
name search
Browse files Browse the repository at this point in the history
  • Loading branch information
midorikocak committed Sep 30, 2017
1 parent 502e4e0 commit a02d013
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,15 @@ public static List<ExtendedCurrency> getAllCurrencies() {
}

public static ExtendedCurrency getCurrencyByISO(String currencyIsoCode) {
currencyIsoCode = currencyIsoCode.toUpperCase();

ExtendedCurrency c = new ExtendedCurrency();
c.setCode(currencyIsoCode);

int i = Arrays.binarySearch(CURRENCIES, c, new ISOCodeComparator());
// Because the data we have is sorted by ISO codes and not by names, we must check all
// currencies one by one

if (i < 0) {
return null;
} else {
return CURRENCIES[i];
for (ExtendedCurrency c : CURRENCIES) {
if (currencyIsoCode.equals(c.getCode())) {
return c;
}
}
return null;
}

public static ExtendedCurrency getCurrencyByName(String currencyName) {
Expand Down

0 comments on commit a02d013

Please sign in to comment.