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

import java.util.LinkedList;
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 = "usePlugin")
public class UsePluginModel {
	private String id;
	private String nickName;
	private String name;
	private List<ParameterModel> parameters;

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

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

	@XmlElement
	public String getNickName() {
		return nickName;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}

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

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

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

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

	public UsePluginModel() {
	}

	public static UsePluginModel createUsePlugin(String id, String name,String nickName,
			List<ParameterModel> initParameters) {
		UsePluginModel result = new UsePluginModel();
		result.setId(id);
		result.setName(name);
		result.setNickName(nickName);
		result.setParameters(initParameters);
		return result;
	}
	public UsePluginModel(String id, String name,
			List<ParameterModel> parameters) {
		this.setId(id);
		this.setName(name);
		this.setNickName(name+"_"+id);
		if (parameters == null) {
			parameters = new LinkedList<ParameterModel>();
		}
		this.setParameters(parameters);
	}
	public UsePluginModel(String id, String name,String nickName,
			List<ParameterModel> parameters) {
		this.setId(id);
		this.setName(name);
		this.setNickName(nickName);
		if (parameters == null) {
			parameters = new LinkedList<ParameterModel>();
		}
		this.setParameters(parameters);
	}
}
