package org.bench4q.share.models.agent.scriptrecord;

import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

import org.bench4q.share.models.agent.ParameterModel;

@XmlRootElement(name = "behaviorModel")
public class BehaviorModel {
	private int id;
	private String use;
	private String name;
	private String type;
	private List<ParameterModel> parameters;

	@XmlElement
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@XmlElement
	public String getUse() {
		return use;
	}

	public void setUse(String use) {
		this.use = use;
	}

	@XmlElement
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@XmlElement
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	@XmlElementWrapper(name = "parameters")
	@XmlElement(name = "parameter")
	public List<ParameterModel> getParameters() {
		return parameters;
	}

	public void setParameters(List<ParameterModel> parameters) {
		this.parameters = parameters;
	}
//
//	public BehaviorModel() {
//	}

	public static BehaviorModel TimerBehaviorBuilder(int id, String name,
			String use, List<ParameterModel> parameters) {
		BehaviorModel behaviorBaseModel = buildBehaviorModelWithoutType(id,
				name, use, parameters);
		behaviorBaseModel.setType("TIMERBEHAVIOR");
		return behaviorBaseModel;
	}

	private static BehaviorModel buildBehaviorModelWithoutType(int id,
			String name, String use, List<ParameterModel> parameters) {
		BehaviorModel behaviorBaseModel = new BehaviorModel();
		behaviorBaseModel.setId(id);
		behaviorBaseModel.setName(name);
		behaviorBaseModel.setUse(use);
		behaviorBaseModel.setParameters(parameters);
		return behaviorBaseModel;
	}

	public static BehaviorModel UserBehaviorBuilder(int id, String name,
			String use, List<ParameterModel> parameters) {
		BehaviorModel behaviorBaseModel = buildBehaviorModelWithoutType(id,
				name, use, parameters);
		behaviorBaseModel.setType("USERBEHAVIOR");
		return behaviorBaseModel;
	}

	public static BehaviorModel ControlBehaviorBuilder(int id, String name,
			String use, List<ParameterModel> parameters) {
		BehaviorModel result = buildBehaviorModelWithoutType(id, name, use,
				parameters);
		result.setType("CONTROLBEHAVIOR");
		return result;
	}
	
//	public static BehaviorModel TimerBehaviorBuilder(String name,
//			String use, List<ParameterModel> parameters) {
//		BehaviorModel behaviorBaseModel = buildBehaviorModelWithoutType(
//				name, use, parameters);
//		behaviorBaseModel.setType("TIMERBEHAVIOR");
//		return behaviorBaseModel;
//	}
//
//	private static BehaviorModel buildBehaviorModelWithoutType(
//			String name, String use, List<ParameterModel> parameters) {
//		BehaviorModel behaviorBaseModel = new BehaviorModel();
//		behaviorBaseModel.setName(name);
//		behaviorBaseModel.setUse(use);
//		behaviorBaseModel.setParameters(parameters);
//		return behaviorBaseModel;
//	}
//
//	public static BehaviorModel UserBehaviorBuilder(String name,
//			String use, List<ParameterModel> parameters) {
//		BehaviorModel behaviorBaseModel = buildBehaviorModelWithoutType(
//				name, use, parameters);
//		behaviorBaseModel.setType("USERBEHAVIOR");
//		return behaviorBaseModel;
//	}
//
//	public static BehaviorModel ControlBehaviorBuilder(String name,
//			String use, List<ParameterModel> parameters) {
//		BehaviorModel result = buildBehaviorModelWithoutType( name, use,
//				parameters);
//		result.setType("CONTROLBEHAVIOR");
//		return result;
//	}
}
