package org.bench4q.share.models.master.statistics;

import java.lang.reflect.Field;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class ScriptBriefResultModel extends SampleModel {
	private long totalSuccessCountFromBegin;
	private long totalFailCountFromBegin;
	private long averageResponseTime;
	private long maxResponseTime;
	private long minResponseTime;
	private long successThroughputThisTime;
	private long failThroughputThisTime;
	private long responseTimeDeviationThisTime;
	private long failRateThisTime;
	private long averageElapsedTime;
	private long planedRunningTime;
	private long vUserCount;

	@XmlElement
	public long getTotalSuccessCountFromBegin() {
		return totalSuccessCountFromBegin;
	}

	public void setTotalSuccessCountFromBegin(long totalSuccessCountFromBegin) {
		this.totalSuccessCountFromBegin = totalSuccessCountFromBegin;
	}

	@XmlElement
	public long getTotalFailCountFromBegin() {
		return totalFailCountFromBegin;
	}

	public void setTotalFailCountFromBegin(long totalFailCountFromBegin) {
		this.totalFailCountFromBegin = totalFailCountFromBegin;
	}

	@XmlElement
	public long getAverageResponseTime() {
		return averageResponseTime;
	}

	public void setAverageResponseTime(long averageResponseTime) {
		this.averageResponseTime = averageResponseTime;
	}

	@XmlElement
	public long getMaxResponseTime() {
		return maxResponseTime;
	}

	public void setMaxResponseTime(long maxResponseTime) {
		this.maxResponseTime = maxResponseTime;
	}

	@XmlElement
	public long getMinResponseTime() {
		return minResponseTime;
	}

	public void setMinResponseTime(long minResponseTime) {
		this.minResponseTime = minResponseTime;
	}

	@XmlElement
	public long getSuccessThroughputThisTime() {
		return successThroughputThisTime;
	}

	public void setSuccessThroughputThisTime(long successThroughputThisTime) {
		this.successThroughputThisTime = successThroughputThisTime;
	}

	@XmlElement
	public long getFailThroughputThisTime() {
		return failThroughputThisTime;
	}

	public void setFailThroughputThisTime(long failThroughputThisTime) {
		this.failThroughputThisTime = failThroughputThisTime;
	}

	@XmlElement
	public long getResponseTimeDeviationThisTime() {
		return responseTimeDeviationThisTime;
	}

	public void setResponseTimeDeviationThisTime(
			long responseTimeDeviationThisTime) {
		this.responseTimeDeviationThisTime = responseTimeDeviationThisTime;
	}

	@XmlElement
	public long getFailRateThisTime() {
		return failRateThisTime;
	}

	public void setFailRateThisTime(long failRateThisTime) {
		this.failRateThisTime = failRateThisTime;
	}

	@XmlElement
	public long getAverageElapsedTime() {
		return averageElapsedTime;
	}

	public void setAverageElapsedTime(long averageElapsedTime) {
		this.averageElapsedTime = averageElapsedTime;
	}

	@XmlElement
	public long getPlanedRunningTime() {
		return planedRunningTime;
	}

	public void setPlanedRunningTime(long planedRunningTime) {
		this.planedRunningTime = planedRunningTime;
	}


	@XmlElement
	public long getvUserCount() {
		return vUserCount;
	}

	public void setvUserCount(long vUserCount) {
		this.vUserCount = vUserCount;
	}

	
	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof ScriptBriefResultModel) || obj == null) {
			return false;
		}
		boolean result = true;
		Field[] fields = this.getClass().getDeclaredFields();
		try {
			for (Field field : fields) {
				field.setAccessible(true);
				if (field.getName() == "finished"
						|| field.getName() == "samplingTime") {
					continue;
				}
				if (field.getLong(this) != field.getLong(obj)) {
					result = false;
					System.out.println(field.getName() + "target :"
							+ field.getLong(obj) + " , this "
							+ field.getLong(this));
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			result = false;
		}
		return result;
	}
}
