} catch (IOException e) {
throw new ExchangeException("JSON parse error", e);
}
List<Wallet> newWallets = new ArrayList<Wallet>();
AccountInfo accountInfo;
synchronized (cachedDataSynchronizationObject) {
if (cachedAccountInfo == null) {
String currency = rawRetObj.getAsset().toString();
BigDecimal balance = rawRetObj.getBalance();
newWallets.add(new Wallet(currency, balance));
}
else {
List<Wallet> oldWallets = cachedAccountInfo.getWallets();
for (Wallet wallet : oldWallets) {
if (wallet.getCurrency().equals(rawRetObj.getAsset())) {
String currency = rawRetObj.getAsset().toString();
BigDecimal balance = rawRetObj.getBalance();
newWallets.add(new Wallet(currency, balance));
}
else {
newWallets.add(wallet);
}
}
}
accountInfo = new AccountInfo(null, newWallets);
cachedAccountInfo = accountInfo;
}
resultMap.put("generic", accountInfo);
resultMap.put("raw", rawRetObj);