package com.bitso.exchange;

import java.math.BigDecimal;

public class BookOrder {
    public String id;
    public String book;
    public BigDecimal price;
    /**
     * Used to indicate the amount of major currency
     *
     * @deprecated use {@link #major} instead.
     */
    @Deprecated
    public BigDecimal amount;
    public BigDecimal major;
    public BigDecimal minor;
    public TYPE type;
    public STATUS status;
    public String created;
    public String updated;
    public String dateTime;

    public static enum TYPE {
        BUY, SELL
    }

    public static enum STATUS {
        ACTIVE, PARTIALLY_FILLED, COMPLETE, CANCELLED
    }

    public BookOrder(BigDecimal price, BigDecimal major) {
        this(price, major, null);
    }

    public BookOrder(BigDecimal price, BigDecimal major, TYPE type) {
        this.price = price;
        this.amount = major;
        this.major = major;
        this.type = type;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("=====\nid=");
        sb.append(id);
        sb.append("\nbook=");
        sb.append(book);
        sb.append("\nprice=");
        sb.append(price);
        sb.append("\nmajor=");
        sb.append(major);
        sb.append("\nminor=");
        sb.append(minor);
        sb.append("\ntype=");
        sb.append(type);
        sb.append("\nstatus=");
        sb.append(status);
        sb.append("\ncreated=");
        sb.append(created);
        sb.append("\nupdated=");
        sb.append(updated);
        sb.append("\n=====");
        return sb.toString();
    }

}

@@ -74,16 +74,49 @@
 ookOrder
+ implements Comparable%3CBookOrder%3E
  %7B%0A    p
@@ -1657,10 +1657,490 @@
 %0A    %7D%0A%0A
+    @Override%0A    public int compareTo(BookOrder o) %7B%0A        if (o.type != this.type) %7B%0A            throw new IllegalStateException(%22Cannot compare two BookOrders of different types!%22);%0A        %7D%0A        if (this.type == TYPE.BUY) %7B%0A            return o.price.compareTo(this.price);%0A        %7D else if (this.type == TYPE.SELL) %7B%0A            return this.price.compareTo(o.price);%0A        %7D%0A        throw new IllegalStateException(%22Cannot compare BookOrders without type!%22);%0A    %7D%0A%0A
 %7D%0A

make BookOrders comparable