Skip to content

Commit edf79ec

Browse files
mathecruzfjtirado
andauthored
Introduce EventType enum (#1646)
* Introduce EventType enum Signed-off-by: Matheus Cruz <matheuscruz.dev@gmail.com> * [Fix #1638] Implementing toString on enum Signed-off-by: Francisco Javier Tirado Sarti <ftirados@ibm.com> --------- Signed-off-by: Matheus Cruz <matheuscruz.dev@gmail.com> Signed-off-by: Francisco Javier Tirado Sarti <ftirados@ibm.com> Co-authored-by: Francisco Javier Tirado Sarti <ftirados@ibm.com>
1 parent e71ed38 commit edf79ec

16 files changed

Lines changed: 118 additions & 0 deletions
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.serverlessworkflow.impl.lifecycle;
17+
18+
import io.serverlessworkflow.impl.LifecycleEvents;
19+
20+
public enum EventType {
21+
TASK_STARTED(LifecycleEvents.TASK_STARTED),
22+
TASK_COMPLETED(LifecycleEvents.TASK_COMPLETED),
23+
TASK_SUSPENDED(LifecycleEvents.TASK_SUSPENDED),
24+
TASK_RESUMED(LifecycleEvents.TASK_RESUMED),
25+
TASK_FAULTED(LifecycleEvents.TASK_FAULTED),
26+
TASK_CANCELLED(LifecycleEvents.TASK_CANCELLED),
27+
TASK_RETRIED(LifecycleEvents.TASK_RETRIED),
28+
WORKFLOW_STARTED(LifecycleEvents.WORKFLOW_STARTED),
29+
WORKFLOW_COMPLETED(LifecycleEvents.WORKFLOW_COMPLETED),
30+
WORKFLOW_SUSPENDED(LifecycleEvents.WORKFLOW_SUSPENDED),
31+
WORKFLOW_RESUMED(LifecycleEvents.WORKFLOW_RESUMED),
32+
WORKFLOW_FAULTED(LifecycleEvents.WORKFLOW_FAULTED),
33+
WORKFLOW_CANCELLED(LifecycleEvents.WORKFLOW_CANCELLED),
34+
WORKFLOW_STATUS_CHANGED(LifecycleEvents.WORKFLOW_STATUS_CHANGED);
35+
36+
private final String lifecycleId;
37+
38+
@Override
39+
public String toString() {
40+
return this.lifecycleId;
41+
}
42+
43+
EventType(String lifecycleId) {
44+
this.lifecycleId = lifecycleId;
45+
}
46+
}

‎impl/core/src/main/java/io/serverlessworkflow/impl/lifecycle/TaskCancelledEvent.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ public class TaskCancelledEvent extends TaskEvent {
2323
public TaskCancelledEvent(WorkflowContext workflow, TaskContext task) {
2424
super(workflow, task);
2525
}
26+
27+
@Override
28+
public EventType type() {
29+
return EventType.TASK_CANCELLED;
30+
}
2631
}

‎impl/core/src/main/java/io/serverlessworkflow/impl/lifecycle/TaskCompletedEvent.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ public class TaskCompletedEvent extends TaskEvent {
2323
public TaskCompletedEvent(WorkflowContext workflow, TaskContext task) {
2424
super(workflow, task);
2525
}
26+
27+
@Override
28+
public EventType type() {
29+
return EventType.TASK_COMPLETED;
30+
}
2631
}

‎impl/core/src/main/java/io/serverlessworkflow/impl/lifecycle/TaskFailedEvent.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ public TaskFailedEvent(WorkflowContext workflow, TaskContext task, Throwable cau
3030
public Throwable cause() {
3131
return cause;
3232
}
33+
34+
@Override
35+
public EventType type() {
36+
return EventType.TASK_FAULTED;
37+
}
3338
}

‎impl/core/src/main/java/io/serverlessworkflow/impl/lifecycle/TaskResumedEvent.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ public class TaskResumedEvent extends TaskEvent {
2323
public TaskResumedEvent(WorkflowContext workflow, TaskContext task) {
2424
super(workflow, task);
2525
}
26+
27+
@Override
28+
public EventType type() {
29+
return EventType.TASK_RESUMED;
30+
}
2631
}

‎impl/core/src/main/java/io/serverlessworkflow/impl/lifecycle/TaskRetriedEvent.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ public class TaskRetriedEvent extends TaskEvent {
2323
public TaskRetriedEvent(WorkflowContext workflow, TaskContext task) {
2424
super(workflow, task);
2525
}
26+
27+
@Override
28+
public EventType type() {
29+
return EventType.TASK_RETRIED;
30+
}
2631
}

‎impl/core/src/main/java/io/serverlessworkflow/impl/lifecycle/TaskStartedEvent.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ public class TaskStartedEvent extends TaskEvent {
2323
public TaskStartedEvent(WorkflowContext workflow, TaskContext task) {
2424
super(workflow, task);
2525
}
26+
27+
@Override
28+
public EventType type() {
29+
return EventType.TASK_STARTED;
30+
}
2631
}

‎impl/core/src/main/java/io/serverlessworkflow/impl/lifecycle/TaskSuspendedEvent.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ public class TaskSuspendedEvent extends TaskEvent {
2323
public TaskSuspendedEvent(WorkflowContext workflow, TaskContext task) {
2424
super(workflow, task);
2525
}
26+
27+
@Override
28+
public EventType type() {
29+
return EventType.TASK_SUSPENDED;
30+
}
2631
}

‎impl/core/src/main/java/io/serverlessworkflow/impl/lifecycle/WorkflowCancelledEvent.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@ public class WorkflowCancelledEvent extends WorkflowEvent {
2222
public WorkflowCancelledEvent(WorkflowContextData workflow) {
2323
super(workflow);
2424
}
25+
26+
@Override
27+
public EventType type() {
28+
return EventType.WORKFLOW_CANCELLED;
29+
}
2530
}

‎impl/core/src/main/java/io/serverlessworkflow/impl/lifecycle/WorkflowCompletedEvent.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ public WorkflowCompletedEvent(WorkflowContextData workflow, WorkflowModel output
3030
public WorkflowModel output() {
3131
return output;
3232
}
33+
34+
@Override
35+
public EventType type() {
36+
return EventType.WORKFLOW_COMPLETED;
37+
}
3338
}

0 commit comments

Comments
 (0)