Map view of the orderbook; asks/bids are snapshot copies so callers can iterate without racing the WsClient thread that keeps applying deltas to the live sides. Synchronized so the scalar fields (timestamp/datetime/nonce/symbol) are read atomically as a group — pairs with Helpers.addElementToObje
()
| 127 | * branch, which takes the same monitor when an exchange handler does e.g. |
| 128 | * `addElementToObject(orderbook, "timestamp", ts)` and then `... "datetime", iso`. */ |
| 129 | public synchronized Map<String, Object> toMap() { |
| 130 | Map<String, Object> result = new HashMap<>(); |
| 131 | result.put("symbol", this.symbol); |
| 132 | result.put("asks", this.asks.snapshot()); |
| 133 | result.put("bids", this.bids.snapshot()); |
| 134 | result.put("timestamp", this.timestamp); |
| 135 | result.put("datetime", this.datetime); |
| 136 | result.put("nonce", this.nonce); |
| 137 | return result; |
| 138 | } |
| 139 | |
| 140 | // ─── Variants ─── |
| 141 |