package org.knowm.xchange.okcoin.v3.dto.marketdata;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.math.BigDecimal;
import java.util.Arrays;

public class OkexOrderBook {

  private final String timestamp;
  private final OkexOrderBookEntry[] bids;
  private final OkexOrderBookEntry[] asks;

  public OkexOrderBook(
      @JsonProperty("timestamp") String timestamp,
      @JsonProperty("bids") Object[][] bids,
      @JsonProperty("asks") Object[][] asks) {

    this.timestamp = timestamp;

    if (bids != null && bids.length > 0) {
      this.bids = new OkexOrderBookEntry[bids.length];
      for (int i = 0; i < bids.length; i++) {
        this.bids[i] = convertToBookEntry(bids[i]);
      }
    } else {
      this.bids = null;
    }

    if (asks != null && asks.length > 0) {
      this.asks = new OkexOrderBookEntry[asks.length];
      for (int i = 0; i < asks.length; i++) {
        this.asks[i] = convertToBookEntry(asks[i]);
      }
    } else {
      this.asks = null;
    }
  }

  private static OkexOrderBookEntry convertToBookEntry(Object[] dataObject) {

    if (dataObject != null && dataObject.length == 3) {
      BigDecimal price = new BigDecimal((String) dataObject[0]);
      BigDecimal volume = new BigDecimal((String) dataObject[1]);
      String numberOfOrders = (String) dataObject[2];
      return new OkexOrderBookEntry(price, volume, numberOfOrders);
    }
    return null;
  }

  public String getTimestamp() {

    return timestamp;
  }

  public OkexOrderBookEntry[] getBids() {

    return bids;
  }

  public OkexOrderBookEntry[] getAsks() {

    return asks;
  }

  @Override
  public String toString() {
    return "OkexOrderBook [timestamp="
        + timestamp
        + ", bids="
        + Arrays.toString(bids)
        + ", asks="
        + Arrays.toString(asks)
        + "]";
  }
}

@@ -116,211 +116,61 @@
 ava.
-math.BigDecimal;%0Aimport java.util.Arrays;%0A%0Apublic class OkexOrderBook %7B%0A%0A  private final String timestamp;%0A  private final OkexOrderBookEntry%5B%5D bids;%0A  private final OkexOrderBookEntry%5B%5D asks;%0A%0A  
+util.Arrays;%0Aimport lombok.Data;%0A%0A@Data%0A
 public 
+class 
 Okex
@@ -182,14 +182,12 @@
 Book
-(%0A    
+ %7B%0A%0A
   @J
@@ -210,16 +210,26 @@
 estamp%22)
+%0A  private
  String 
@@ -237,22 +237,19 @@
 imestamp
-,%0A    
+;%0A%0A
   @JsonP
@@ -267,606 +267,70 @@
 ds%22)
- Object%5B%5D%5B%5D bids,%0A      @JsonProperty(%22asks%22) Object%5B%5D%5B%5D asks) %7B%0A%0A    this.timestamp = timestamp;%0A%0A    if (bids != null && bids.length %3E 0) %7B%0A      this.bids = new OkexOrderBookEntry%5Bbids.length%5D;%0A      for (int i = 0; i %3C bids.length; i++) %7B%0A        this.bids%5Bi%5D = convertToBookEntry(bids%5Bi%5D);%0A      %7D%0A    %7D else %7B%0A      this.bids = null;%0A    %7D%0A%0A    if (asks != null && asks.length %3E 0) %7B%0A      this.asks = new OkexOrderBookEntry%5Basks.length%5D;%0A      for (int i = 0; i %3C asks.length; i++) %7B%0A        this.asks%5Bi%5D = convertToBookEntr
+%0A  private OkexOrderBookEntry%5B%5D bids;%0A%0A  @JsonPropert
 y(
+%22
 asks
-%5Bi%5D);%0A      %7D%0A    %7D else %7B%0A      this.asks = null;%0A    %7D%0A  %7D%0A
+%22)
 %0A  p
@@ -340,15 +340,8 @@
 ate 
-static 
 Okex
@@ -358,387 +358,16 @@
 ntry
- convertToBookEntry(Object%5B%5D dataObject) %7B%0A%0A    if (dataObject != null && dataObject.length == 3) %7B%0A      BigDecimal price = new BigDecimal((String) dataObject%5B0%5D);%0A      BigDecimal volume = new BigDecimal((String) dataObject%5B1%5D);%0A      String numberOfOrders = (String) dataObject%5B2%5D;%0A      return new OkexOrderBookEntry(price, volume, numberOfOrders);%0A    %7D%0A    return null;%0A  %7D
+%5B%5D asks;
 %0A%0A  

Order Book implementation