public Map<String, Object> adaptBalancesChanged(String data) {
Map<String, Object> resultMap = new HashMap<String, Object>();
CoinfloorAssetBalance rawRetObj;
try {
rawRetObj = streamObjectMapper.readValue(data, CoinfloorAssetBalance.class);
} 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);