All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jquicker.timer.TimerTask Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
package com.jquicker.timer;

import java.lang.reflect.Method;

import com.jquicker.annotation.timer.Scheduled.Policy;
import com.jquicker.commons.util.JsonUtils;

public class TimerTask {

	private String id; // 任务ID,全局唯一
	private String name; // 任务名称
	private Object task; // 任务类的实例
	private Class clazz; // 任务类的class
	private Method method; // 任务类的Method
	private long period; // 周期(秒)
	private String cron; // cron表达式
	private Policy policy = Policy.atFixedRate; // 执行策略
	private boolean concurrent = true; // 是否允许同一个任务并发执行
	private String first; // 第一次执行时间([yyyy-MM-dd] HH:mm:ss),为空时在初始化后立即执行
	private String last; // 最后一次执行时间(yyyy-MM-dd HH:mm:ss),超过该时间后不再执行
	private long limit; // 限制执行次数,若limit小于等于0将不限次数
	private String description; // 任务描述
	private boolean enable = true;
	private boolean isCyclical;
	private long delay; // 周期(秒)

	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 Object getTask() {
		return task;
	}

	public void setTask(Object task) {
		this.task = task;
	}

	public Class getClazz() {
		return clazz;
	}

	public void setClazz(Class clazz) {
		this.clazz = clazz;
	}

	public Method getMethod() {
		return method;
	}

	public void setMethod(Method method) {
		this.method = method;
	}

	public Long getPeriod() {
		return period;
	}

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

	public String getCron() {
		return cron;
	}

	public void setCron(String cron) {
		this.cron = cron;
	}

	public Policy getPolicy() {
		return policy;
	}

	public void setPolicy(Policy policy) {
		this.policy = policy;
	}

	public boolean isConcurrent() {
		return concurrent;
	}

	public void setConcurrent(boolean concurrent) {
		this.concurrent = concurrent;
	}

	public String getFirst() {
		return first;
	}

	public void setFirst(String first) {
		this.first = first;
	}

	public String getLast() {
		return last;
	}

	public void setLast(String last) {
		this.last = last;
	}

	public long getLimit() {
		return limit;
	}

	public void setLimit(long limit) {
		this.limit = limit;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public boolean isEnable() {
		return enable;
	}

	public void setEnable(boolean enable) {
		this.enable = enable;
	}

	public boolean isCyclical() {
		if(period > 0){
			isCyclical = true;
		}
		return isCyclical;
	}

	public void setCyclical(boolean isCyclical) {
		this.isCyclical = isCyclical;
	}

	public long getDelay() {
		return delay;
	}

	public void setDelay(long delay) {
		this.delay = delay;
	}

	@Override
	public String toString() {
		return JsonUtils.toJsonString(this);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy