rawRetObj = streamObjectMapper.readValue(data, CoinfloorOrder.class);
} catch (IOException e) {
throw new ExchangeException("JSON parse error", e);
}
Trade trade;
synchronized (cachedDataSynchronizationObject) {
List<LimitOrder> bidList = (cachedOrderBook == null ? new ArrayList<LimitOrder>() : cachedOrderBook.getBids());
List<LimitOrder> askList = (cachedOrderBook == null ? new ArrayList<LimitOrder>() : cachedOrderBook.getAsks());
if (rawRetObj.getBidId() != 0) {
for (int i = 0; i < bidList.size(); i++) {
if (bidList.get(i).getId().equals(String.valueOf(rawRetObj.getBidId()))) {
bidList.remove(i);
break;
}
}
}
if (rawRetObj.getAskId() != 0) {
for (int i = 0; i < askList.size(); i++) {
if (askList.get(i).getId().equals(String.valueOf(rawRetObj.getAskId()))) {
askList.remove(i);
break;
}
}
}
cachedOrderBook = new OrderBook(new Date(), askList, bidList);
OrderType type = (rawRetObj.getBidId() > rawRetObj.getAskId() ? OrderType.BID : OrderType.ASK);
BigDecimal limitPrice = rawRetObj.getPrice();
trade =
new Trade(type, rawRetObj.getBaseQty(), new CurrencyPair(rawRetObj.getBase().toString(), rawRetObj.getCounter().toString()), limitPrice, new Date(), String.valueOf(rawRetObj.getId()));
List<Trade> newTradesList = (cachedTrades == null ? new ArrayList<Trade>() : cachedTrades.getTrades());
newTradesList.add(trade);
Trades newCachedTrades = new Trades(newTradesList, TradeSortType.SortByID);