JAL-3878 Move status precedence list to JobStatus class
authorMateusz Warowny <mmzwarowny@dundee.ac.uk>
Tue, 5 Apr 2022 12:12:03 +0000 (14:12 +0200)
committerMateusz Warowny <mmzwarowny@dundee.ac.uk>
Tue, 5 Apr 2022 12:12:03 +0000 (14:12 +0200)
src/jalview/ws2/actions/AbstractPollableTask.java
src/jalview/ws2/api/JobStatus.java

index 6ff5749..bf58b13 100644 (file)
@@ -219,35 +219,16 @@ public abstract class AbstractPollableTask<T extends BaseJob, R> implements Task
     for (BaseJob job : jobs)
     {
       JobStatus status = job.getStatus();
-      int jobPrecedence = ArrayUtils.indexOf(statusPrecedence, status);
+      int jobPrecedence = ArrayUtils.indexOf(JobStatus.statusPrecedence, status);
       if (precedence < jobPrecedence)
         precedence = jobPrecedence;
     }
     if (precedence >= 0)
     {
-      setStatus(statusPrecedence[precedence]);
+      setStatus(JobStatus.statusPrecedence[precedence]);
     }
   }
 
-  /**
-   * A precedence order of job statuses used to compute the overall task status.
-   */
-  private static JobStatus[] statusPrecedence = {
-      JobStatus.INVALID, // all must be invalid for task to be invalid
-      JobStatus.COMPLETED, // all but invalid must be completed for task to be
-                           // completed
-      JobStatus.UNKNOWN, // unknown prevents successful completion but not
-                         // running or failure
-      JobStatus.READY,
-      JobStatus.SUBMITTED,
-      JobStatus.QUEUED,
-      JobStatus.RUNNING,
-      JobStatus.CANCELLED, // if any is terminated unsuccessfully, the task is
-                           // failed
-      JobStatus.FAILED,
-      JobStatus.SERVER_ERROR
-  };
-
   @Override
   public void cancel()
   {
index 0334737..3341a69 100644 (file)
@@ -49,4 +49,23 @@ public enum JobStatus
       throw new AssertionError("non-exhaustive switch statement");
     }
   }
+
+  /**
+   * A precedence order of job statuses used to compute the overall task status.
+   */
+  public static final JobStatus[] statusPrecedence = {
+      JobStatus.INVALID, // all must be invalid for task to be invalid
+      JobStatus.COMPLETED, // all but invalid must be completed for task to be
+                           // completed
+      JobStatus.UNKNOWN, // unknown prevents successful completion but not
+                         // running or failure
+      JobStatus.READY,
+      JobStatus.SUBMITTED,
+      JobStatus.QUEUED,
+      JobStatus.RUNNING,
+      JobStatus.CANCELLED, // if any is terminated unsuccessfully, the task is
+                           // failed
+      JobStatus.FAILED,
+      JobStatus.SERVER_ERROR
+  };
 }