Last active
October 8, 2015 08:27
-
-
Save michalbcz/0c90bfb5cdc806db8ef4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void test(List<ExchangeRate> exchangeRates) { | |
Map<String, ExchangeRate> rateType11Map = new HashMap<String, ExchangeRate>(); | |
Map<String, ExchangeRate> rateType12Map = new HashMap<String, ExchangeRate>(); | |
Collections.sort(exchangeRates, new Comparator<ExchangeRate>() { | |
@Override | |
public int compare(ExchangeRate e1, ExchangeRate e2) { | |
return ComparisonChain.start() | |
.compare(e1.getRateCurrency(), e2.getRateCurrency()) | |
.compare(e1.getRateType(), e2.getRateType()) | |
.result(); | |
} | |
}); | |
for (ExchangeRate exchangeRate : exchangeRates) { | |
String rateCurrency = exchangeRate.getRateCurrency(); | |
if (rateType11Map.containsKey(rateCurrency)) { | |
rateType12Map.put(rateCurrency, exchangeRate); | |
} else { | |
rateType11Map.put(rateCurrency, exchangeRate); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment