public synchronized void addToBook(Quote q) throws Exception { Price sellQuote = q.getQuoteSide("SELL").getPrice(); Price buyQuote = q.getQuoteSide("BUY").getPrice(); if (sellQuote.lessOrEqual(buyQuote)) throw new DataValidationException("SELL Price is less than or Equal to BUY Price"); if (q.getQuoteSide("SELL").getOriginalVolume() <= 0 || q.getQuoteSide("BUY").getOriginalVolume() <= 0) throw new DataValidationException("BUY or SELL side is less than or equal to zero"); if (this.userQuotes.contains(q.getUserName())) { buySide.removeQuote(q.getUserName()); sellSide.removeQuote(q.getUserName()); this.updateCurrentMarket(); } this.addToBook(BookSide.BUY, q.getQuoteSide("BUY")); this.addToBook(BookSide.SELL, q.getQuoteSide("SELL")); userQuotes.add(q.getUserName()); this.updateCurrentMarket(); }