1717package feast .core .model ;
1818
1919import feast .core .IngestionJobProto .IngestionJobStatus ;
20- import java .util .Arrays ;
21- import java .util .Collection ;
22- import java .util .Collections ;
2320import java .util .Map ;
21+ import java .util .Set ;
2422
2523public enum JobStatus {
2624 /** Job status is not known. */
@@ -53,33 +51,41 @@ public enum JobStatus {
5351 /** job has been suspended */
5452 SUSPENDED ;
5553
56- private static final Collection <JobStatus > TERMINAL_STATE =
57- Collections .unmodifiableList (Arrays .asList (COMPLETED , ABORTED , ERROR ));
54+ private static final Set <JobStatus > TERMINAL_STATES = Set .of (COMPLETED , ABORTED , ERROR );
5855
5956 /**
60- * Get a collection of terminal job state .
57+ * Get the set of terminal job states .
6158 *
62- * <p>Terminal job state is final and will not change to any other state.
59+ * <p>A terminal job state is final and will not change to any other state.
6360 *
64- * @return collection of terminal job state .
61+ * @return set of terminal job states .
6562 */
66- public static Collection <JobStatus > getTerminalState () {
67- return TERMINAL_STATE ;
63+ public static Set <JobStatus > getTerminalStates () {
64+ return TERMINAL_STATES ;
6865 }
6966
70- private static final Collection <JobStatus > TRANSITIONAL_STATES =
71- Collections .unmodifiableList (Arrays .asList (PENDING , ABORTING , SUSPENDING ));
67+ private static final Set <JobStatus > TRANSITIONAL_STATES = Set .of (PENDING , ABORTING , SUSPENDING );
7268
7369 /**
74- * Get Transitional Job Status states. Transitionals states are assigned to jobs that
70+ * Get Transitional Job Status states. Transitional states are assigned to jobs that are
7571 * transitioning to a more stable state (ie SUSPENDED, ABORTED etc.)
7672 *
77- * @return Collection of transitional Job Status states.
73+ * @return set of transitional Job Status states.
7874 */
79- public static final Collection <JobStatus > getTransitionalStates () {
75+ public static Set <JobStatus > getTransitionalStates () {
8076 return TRANSITIONAL_STATES ;
8177 }
8278
79+ /** @return true if this {@code JobStatus} is a terminal state. */
80+ public boolean isTerminal () {
81+ return getTerminalStates ().contains (this );
82+ }
83+
84+ /** @return true if this {@code JobStatus} is a transitional state. */
85+ public boolean isTransitional () {
86+ return getTransitionalStates ().contains (this );
87+ }
88+
8389 private static final Map <JobStatus , IngestionJobStatus > INGESTION_JOB_STATUS_MAP =
8490 Map .of (
8591 JobStatus .UNKNOWN , IngestionJobStatus .UNKNOWN ,
@@ -95,7 +101,7 @@ public static final Collection<JobStatus> getTransitionalStates() {
95101 /**
96102 * Convert a Job Status to Ingestion Job Status proto
97103 *
98- * @return IngestionJobStatus proto derieved from this job status
104+ * @return IngestionJobStatus proto derived from this job status
99105 */
100106 public IngestionJobStatus toProto () {
101107 // maps job models job status to ingestion job status
0 commit comments