package com.uas.search.console.b2b.schedule.model;

import java.util.Objects;

import com.uas.search.console.b2b.schedule.service.Executable;

/**
 * 定时任务信息
 * 
 * @author sunyj
 * @since 2016年12月19日 上午10:21:28
 */
public class TaskInformation {
	/**
	 * 任务标题
	 */
	private String title;

	/**
	 * 所执行的任务
	 */
	private Executable command;

	/**
	 * 第一次执行的延迟时间间隔（毫秒）
	 */
	private long initialDelay;

	/**
	 * 两次任务之间的等待时间间隔（毫秒）
	 */
	private long period;

	public TaskInformation() {
		super();
	}

	public TaskInformation(String title, Executable command, long initialDelay, long period) {
		super();
		this.title = title;
		this.command = command;
		this.initialDelay = initialDelay;
		this.period = period;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Executable getCommand() {
		return command;
	}

	public void setCommand(Executable command) {
		this.command = command;
	}

	public long getInitialDelay() {
		return initialDelay;
	}

	public void setInitialDelay(long initialDelay) {
		this.initialDelay = initialDelay;
	}

	public long getPeriod() {
		return period;
	}

	public void setPeriod(long period) {
		this.period = period;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null || getClass() != obj.getClass() || !(obj instanceof TaskInformation)) {
			return false;
		}
		TaskInformation other = (TaskInformation) obj;
		// command不好比较，不进行比较
		return Objects.equals(title, other.getTitle()) && initialDelay == other.getInitialDelay()
				&& period == other.getPeriod();
	}

	@Override
	public String toString() {
		return "TaskInformation [title=" + title + ", initialDelay=" + initialDelay + ", period=" + period + "]";
	}

}
