diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2013-04-20 15:43:01 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2013-04-20 15:43:01 +0200 |
commit | 637dddf11f5d60b35c9696914e1e2658b2ddc611 (patch) | |
tree | ef320c1950d78163dd0cc3247bee172f4e3e32ff /src/main/java/io/trygvis/queue/Task.java | |
parent | c274d9177e4a495e7b793120dfd1ce12fa5632c7 (diff) | |
download | quartz-based-queue-637dddf11f5d60b35c9696914e1e2658b2ddc611.tar.gz quartz-based-queue-637dddf11f5d60b35c9696914e1e2658b2ddc611.tar.bz2 quartz-based-queue-637dddf11f5d60b35c9696914e1e2658b2ddc611.tar.xz quartz-based-queue-637dddf11f5d60b35c9696914e1e2658b2ddc611.zip |
wip
Diffstat (limited to 'src/main/java/io/trygvis/queue/Task.java')
-rwxr-xr-x | src/main/java/io/trygvis/queue/Task.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/main/java/io/trygvis/queue/Task.java b/src/main/java/io/trygvis/queue/Task.java new file mode 100755 index 0000000..7f64c77 --- /dev/null +++ b/src/main/java/io/trygvis/queue/Task.java @@ -0,0 +1,55 @@ +package io.trygvis.queue; + +import java.util.*; + +public class Task { + + public final long id; + + public final String queue; + + public final Date scheduled; + + public final Date lastRun; + + public final int runCount; + + public final Date completed; + + public final List<String> arguments; + + Task(long id, String queue, Date scheduled, Date lastRun, int runCount, Date completed, List<String> arguments) { + this.id = id; + this.queue = queue; + this.scheduled = scheduled; + this.lastRun = lastRun; + this.runCount = runCount; + this.completed = completed; + + this.arguments = arguments; + } + + public Task registerRun() { + return new Task(id, queue, scheduled, new Date(), runCount + 1, completed, arguments); + } + + public Task registerComplete(Date completed) { + return new Task(id, queue, scheduled, lastRun, runCount, new Date(), arguments); + } + + public String toString() { + return "Task{" + + "id=" + id + + ", queue=" + queue + + ", scheduled=" + scheduled + + ", lastRun=" + lastRun + + ", runCount=" + runCount + + ", completed=" + completed + + ", arguments='" + arguments + '\'' + + '}'; + } + + public boolean isDone() { + return completed != null; + } +} |