From 24f8b04fb97e16d9576968db092acf8a8363b0b4 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 13 Nov 2019 17:08:47 +0100 Subject: Add isFinished() to Task --- .../main/java/org/openslx/taskmanager/api/AbstractTask.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/api/src/main/java/org/openslx/taskmanager/api/AbstractTask.java b/api/src/main/java/org/openslx/taskmanager/api/AbstractTask.java index d284ecf..4586c3d 100644 --- a/api/src/main/java/org/openslx/taskmanager/api/AbstractTask.java +++ b/api/src/main/java/org/openslx/taskmanager/api/AbstractTask.java @@ -287,6 +287,19 @@ public abstract class AbstractTask implements Runnable return false; return this.removalDeadline != 0 && System.currentTimeMillis() > this.removalDeadline; } + + /** + * Check whether the given task is finished, i.e. either failed or succeeded, + * or couldn't be started because its parent failed, + * but is not running or still waiting for execution. + * + * @return true if task finished running or was not able to start + */ + public final boolean isFinished() + { + StatusCode sc = getStatusCode(); + return sc != StatusCode.TASK_WAITING && sc != StatusCode.TASK_PROCESSING; + } /** * Execute the task, wrapped in some sanity checks. -- cgit v1.2.3-55-g7522