package org.knowm.xchange.dto.trade;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

import org.knowm.xchange.dto.Order;

/**
 * <p>
 * DTO representing open orders
 * </p>
 * <p>
 * Open orders are orders that you have placed with the exchange that have not yet been matched to a counter-party.
 * </p>
 */
public final class OpenOrders implements Serializable {

  private final List<LimitOrder> openOrders;
  private final List<Order> hiddenOrders;

  /**
   * Constructor
   *
   * @param openOrders The list of open orders
   */
  public OpenOrders(List<LimitOrder> openOrders) {
    this.openOrders = openOrders;
    this.hiddenOrders = Collections.emptyList();
  }

  /**
   * Constructor
   *
   * @param openOrders The list of open orders
   * @param hiddenOrders The list of orders which are active but hidden from the order book.
   */
  public OpenOrders(List<LimitOrder> openOrders, List<Order> hiddenOrders) {
    this.openOrders = openOrders;
    this.hiddenOrders = hiddenOrders;
  }

  /**
   * @return Orders which are shown on the order book.
   */
  public List<LimitOrder> getOpenOrders() {
    return openOrders;
  }

  /**
   * @return Orders which are not shown on the order book, such as untriggered stop orders.
   */
  public List<Order> getHiddenOrders() {
    return hiddenOrders;
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    addToToString(sb, getOpenOrders(), "Open orders");
    addToToString(sb, getHiddenOrders(), "Hidden orders");
    return sb.toString();
  }

  private void addToToString(StringBuilder sb, List<? extends Order> orders, String description) {
    sb.append(description);
    sb.append(": ");
    if (orders.isEmpty()) {
      sb.append("None\n");
    } else {
      sb.append("\n");
      for (Order order : orders) {
        sb.append("  [order=");
        sb.append(order.toString());
        sb.append("]\n");
      }
    }
  }
}
package org.knowm.xchange.dto.trade;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

import org.knowm.xchange.dto.Order;

/**
 * <p>
 * DTO representing open orders
 * </p>
 * <p>
 * Open orders are orders that you have placed with the exchange that have not yet been matched to a counter-party.
 * </p>
 */
public final class OpenOrders implements Serializable {

  private final List<LimitOrder> openOrders;
  private final List<? extends Order> hiddenOrders;

  /**
   * Constructor
   *
   * @param openOrders The list of open orders
   */
  public OpenOrders(List<LimitOrder> openOrders) {
    this.openOrders = openOrders;
    this.hiddenOrders = Collections.emptyList();
  }

  /**
   * Constructor
   *
   * @param openOrders The list of open orders
   * @param hiddenOrders The list of orders which are active but hidden from the order book.
   */
  public OpenOrders(List<LimitOrder> openOrders, List<Order> hiddenOrders) {
    this.openOrders = openOrders;
    this.hiddenOrders = hiddenOrders;
  }

  /**
   * @return Orders which are shown on the order book.
   */
  public List<LimitOrder> getOpenOrders() {
    return openOrders;
  }

  /**
   * @return Orders which are not shown on the order book, such as untriggered stop orders.
   */
  public List<? extends Order> getHiddenOrders() {
    return hiddenOrders;
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    addToToString(sb, getOpenOrders(), "Open orders");
    addToToString(sb, getHiddenOrders(), "Hidden orders");
    return sb.toString();
  }

  private void addToToString(StringBuilder sb, List<? extends Order> orders, String description) {
    sb.append(description);
    sb.append(": ");
    if (orders.isEmpty()) {
      sb.append("None\n");
    } else {
      sb.append("\n");
      for (Order order : orders) {
        sb.append("  [order=");
        sb.append(order.toString());
        sb.append("]\n");
      }
    }
  }
}
Tweak to correctly wildcard generic getter