1 package org.oxerr.okcoin.websocket.dto; 2 3 import java.util.stream.Collectors; 4 5 import javax.json.JsonObject; 6 import javax.json.JsonValue; 7 8 9 public class OrderResult extends org.oxerr.okcoin.rest.dto.OrderResult { 10 11 private static final long serialVersionUID = 2015030701L; 12 13 private static final Order[] EMPTY_ORDERS = new Order[0]; 14 15 public OrderResult(JsonValue jsonValue) { 16 this((JsonObject) jsonValue); 17 } 18 19 public OrderResult(JsonObject jsonObject) { 20 super( 21 jsonObject.getBoolean("result"), 22 0, 23 jsonObject 24 .getJsonArray("orders") 25 .stream() 26 .map(v -> { 27 JsonObject o = (JsonObject) v; 28 return new Order(o); 29 }) 30 .collect(Collectors.toList()) 31 .toArray(EMPTY_ORDERS) 32 ); 33 } 34 35 }