package com.bitso.exchange;

import java.math.BigDecimal;

public class BookOrder implements Comparable<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();
    }

    @Override
    public int compareTo(BookOrder o) {
        if (o.type != this.type) {
            throw new IllegalStateException("Cannot compare two BookOrders of different types!");
        }
        if (this.type == TYPE.BUY) {
            return o.price.compareTo(this.price);
        } else if (this.type == TYPE.SELL) {
            return this.price.compareTo(o.price);
        }
        throw new IllegalStateException("Cannot compare BookOrders without type!");
    }

}

@@ -52,16 +52,51 @@
 cimal;%0A%0A
+import com.bitso.helpers.Helpers;%0A%0A
 public c
@@ -1071,623 +1071,40 @@
     
-StringBuilder sb = new StringBuilder();%0A        sb.append(%22=====%5Cnid=%22);%0A        sb.append(id);%0A        sb.append(%22%5Cnbook=%22);%0A        sb.append(book);%0A        sb.append(%22%5Cnprice=%22);%0A        sb.append(price);%0A        sb.append(%22%5Cnmajor=%22);%0A        sb.append(major);%0A        sb.append(%22%5Cnminor=%22);%0A        sb.append(minor);%0A        sb.append(%22%5Cntype=%22);%0A        sb.append(type);%0A        sb.append(%22%5Cnstatus=%22);%0A        sb.append(status);%0A        sb.append(%22%5Cncreated=%22);%0A        sb.append(created);%0A        sb.append(%22%5Cnupdated=%22);%0A        sb.append(updated);%0A        sb.append(%22%5Cn=====%22);%0A        return sb.toString(
+return Helpers.fieldPrinter(this
 );%0A 

replace with helper function