package com.unis.detectionnum.server.schedule.pojo;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;


public class TaskPojo {

	private String id;

	private String name;

	private String cronExpression;

	private Class<?> executeJobClass;
	
	private String sbCode;

	private final Map<String, Object> params = new HashMap<String, Object>();

	/**
	 * params.
	 * 
	 * @return the params
	 * @since JDK 1.6
	 */
	public Map<String, Object> getParams() {
		return params;
	}

	public String getId() {
		return id;
	}

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

	public String getName() {
		return name;
	}

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

	public void addParam(String key, Object value) {
		this.params.put(key, value);
	}

	public String getCronExpression() {
		return cronExpression;
	}

	public void setCronExpression(String cronExpression) {
		this.cronExpression = cronExpression;
	}

	public Class<?> getExecuteJobClass() {
		return executeJobClass;
	}

	public void setExecuteJobClass(Class<?> executeJobClass) {
		this.executeJobClass = executeJobClass;
	}

	public String getSbCode() {
		return sbCode;
	}

	public void setSbCode(String sbCode) {
		this.sbCode = sbCode;
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		return new HashCodeBuilder(1018984965, -1718880873).appendSuper(super.hashCode()).append(this.executeJobClass)
				.append(this.cronExpression).toHashCode();
	}

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	@Override
	public boolean equals(Object object) {
		if (!(object instanceof TaskPojo)) {
			return false;
		}
		TaskPojo rhs = (TaskPojo) object;
		boolean result = new EqualsBuilder().append(this.executeJobClass, rhs.executeJobClass)
				.append(this.cronExpression, rhs.cronExpression).isEquals();
		return result;
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return new ToStringBuilder(this).appendSuper(super.toString()).append("executeJobClass", this.executeJobClass)
				.append("params", this.params).append("cronExpression", this.cronExpression).toString();
	}

}
