/***********************************************************************************************************************
 *
 * 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;

/**
 * Immutable class. This execution structure is based on the structure
 * ExecutionReport from FIX 4.4. "Never changing" fields are available through the
 * Order object, like for instance Side and Symbol. The rest of the fields are
 * available via at the root level of this structure because they are
 * potentially different at each execution
 * 
 * @author embosfer
 *
 */
public class ExecutionReport {

	private final Order order;

	private final String execID;
	private final char execType;
	private final OrdStatus ordStatus;
	private final double avgPx;
	private final double cumQty;
	private final double leavesQty;

	// non mandatory
	private final double lastQty;
	private final double lastPx;

	public static class Builder {
		// mandatory fields
		private final Order order;
		private char execType;

		// optional fields
		private double lastQty;
		private double lastPx;

		public Builder(Order order) {
			this.order = order;
		}

		public Builder execType(char execType) {
			this.execType = execType;
			return this;
		}

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

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

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

	}

	private ExecutionReport(Builder builder) {
		this.execID = "E" + System.currentTimeMillis(); // ensure unicity
		this.order = builder.order;
		this.avgPx = builder.order.getAvgPx();
		this.cumQty = builder.order.getCumQty();
		this.execType = builder.execType;
		this.lastPx = builder.lastPx;
		this.lastQty = builder.lastQty;
		this.leavesQty = builder.order.getLeavesQty();
		this.ordStatus = builder.order.getOrdStatus();
	}

	public String getExecID() {
		return execID;
	}

	public double getAvgPx() {
		return avgPx;
	}

	public double getCumQty() {
		return cumQty;
	}

	public char getExecType() {
		return execType;
	}

	public double getLastPx() {
		return lastPx;
	}

	public double getLastQty() {
		return lastQty;
	}

	public double getLeavesQty() {
		return leavesQty;
	}

	public Order getOrder() {
		return order;
	}

	public OrdStatus getOrdStatus() {
		return ordStatus;
	}

}

@@ -1306,23 +1306,23 @@
  through
+%0A *
  the
-%0A *
  Order o
@@ -1385,23 +1385,23 @@
 e fields
+%0A *
  are
-%0A *
  availab
@@ -3351,10 +3351,477 @@
 us;%0A%09%7D%0A%0A
+%09@Override%0A%09public String toString() %7B%0A%09%09StringBuilder builder = new StringBuilder(%22%5BExecutionReport %22);%0A%09%09builder.append(%22execID:%22).append(execID).append(%22 execType:%22).append(execType).append(ordStatus)%0A%09%09%09%09.append(%22 lastQty:%22).append(lastQty).append(%22 lastPx:%22).append(lastPx).append(%22 leavesQty:%22)%0A%09%09%09%09.append(leavesQty).append(%22 cumQty:%22).append(cumQty).append(%22 avgPx:%22).append(avgPx).append(%22 %22)%0A%09%09%09%09.append(order).append(%22%5D%22);%0A%09%09return builder.toString();%0A%09%7D%0A%0A
 %7D%0A

Add a toString method for logging purposes