/***********************************************************************************************************************
 *
 * FixBro - an open source FIX broker (sell side) simulator
 * =========================================================
 *
 * Copyright (C) 2016 by Emilio Bosch Ferrando
 * https://github.com/embosfer
 *
 ***********************************************************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 *
 ***********************************************************************************************************************/
package com.embosfer.fixbro.model.messages;

import java.util.Date;

import com.embosfer.fixbro.model.tags.OrdType;
import com.embosfer.fixbro.model.tags.Side;

/**
 * Class representing a 35=D message
 * 
 * @author embosfer
 *
 */
public class NewOrderSingle {

	// MANDATORY FIELDS
	private final String clOrdID; // 11
	private final String symbol; // 55
	private final Side side; // 54
	private final Date transactTime; // 60
	private final double orderQty; // 38
	private final OrdType ordType; // 40

	// non mandatory
	private Double price; // 44

	private NewOrderSingle(Builder builder) {
		this.clOrdID = builder.clOrdID;
		this.symbol = builder.symbol;
		this.side = builder.side;
		this.transactTime = builder.transactTime;
		this.orderQty = builder.orderQty;
		this.ordType = builder.ordType;
		this.price = builder.price;
	}

	public String getClOrdID() {
		return clOrdID;
	}

	public String getSymbol() {
		return symbol;
	}

	public Side getSide() {
		return side;
	}

	public Date getTransactTime() {
		return transactTime;
	}

	public double getOrderQty() {
		return orderQty;
	}

	public OrdType getOrdType() {
		return ordType;
	}

	public double getPrice() {
		return price;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder("[NewOrderSingle ");
		builder.append("clOrdID:").append(clOrdID).append(" orderQty:").append(orderQty).append(" ordType:")
				.append(ordType).append(" price:").append(price).append(" side:").append(side).append(" symbol:")
				.append(symbol).append(" transactTime:").append(transactTime).append("]");
		return builder.toString();
	}

	public final static class Builder {

		private String clOrdID;
		private String symbol;
		private Side side;
		private Date transactTime;
		private double orderQty;
		private OrdType ordType;

		// non mandatory
		private Double price;

		public Builder() {
		}

		public Builder clOrdID(String clOrdID) {
			this.clOrdID = clOrdID;
			return this;
		}

		public Builder side(char side) {
			this.side = Side.valueOf(side);
			return this;
		}

		public Builder symbol(String sym) {
			this.symbol = sym;
			return this;
		}

		public Builder transactTime(Date tt) {
			this.transactTime = (Date) tt.clone();
			return this;
		}

		public Builder orderQty(double qty) {
			this.orderQty = qty;
			return this;
		}

		public Builder ordType(char type) {
			this.ordType = OrdType.valueOf(type);
			return this;
		}

		public Builder price(double px) {
			this.price = px;
			return this;
		}

		public NewOrderSingle build() {
			return new NewOrderSingle(this);
		}
	}

}

@@ -1402,16 +1402,58 @@
  FIELDS%0A
+%09private final String senderCompID; // 49%0A
 %09private
@@ -1481,16 +1481,16 @@
 ; // 11%0A
-
 %09private
@@ -1757,16 +1757,60 @@
 lder) %7B%0A
+%09%09this.senderCompID = builder.senderCompID;%0A
 %09%09this.c
@@ -2526,16 +2526,62 @@
 append(%22
+senderCompID:%22).append(senderCompID).append(%22 
 clOrdID:
@@ -2619,16 +2619,21 @@
 erQty:%22)
+%0A%09%09%09%09
 .append(
@@ -2661,21 +2661,16 @@
 dType:%22)
-%0A%09%09%09%09
 .append(
@@ -2722,24 +2722,29 @@
 nd(%22 side:%22)
+%0A%09%09%09%09
 .append(side
@@ -2763,21 +2763,16 @@
 ymbol:%22)
-%0A%09%09%09%09
 .append(
@@ -2824,16 +2824,21 @@
 actTime)
+%0A%09%09%09%09
 .append(
@@ -2914,16 +2914,47 @@
 lder %7B%0A%0A
+%09%09private String senderCompID;%0A
 %09%09privat
@@ -3145,16 +3145,16 @@
 price;%0A%0A
-
 %09%09public
@@ -3165,24 +3165,137 @@
 lder() %7B%0A%09%09%7D
+%0A%09%09%0A%09%09public Builder senderCompID(String senderCompID) %7B%0A%09%09%09this.senderCompID = senderCompID;%0A%09%09%09return this;%0A%09%09%7D
 %0A%0A%09%09public B

Add senderCompID