c32645cadb319e8ddd06b5ab19883de58bfd3077
[vid.git] / vid-app-common / src / main / java / org / onap / vid / job / JobCommand.java
1 package org.onap.vid.job;
2
3 import java.util.Map;
4 import java.util.UUID;
5
6
7 /**
8  * A callable instance, with serializable characteristics.
9  * Represents a step in a chain of steps, which eventualy
10  * resides into a packing Job.
11  */
12 public interface JobCommand {
13
14     /**
15      * Initialize the command state
16      * @param jobUuid Parent job's uuid
17      * @param data An input to be set into the command. Each implementation may expect different keys in the map.
18      * @return Returns itself
19      */
20     default JobCommand init(UUID jobUuid, Map<String, Object> data) {
21         return this;
22     }
23
24     /**
25      * @return Returns the inner state of the command. This state, once passed into init(), should
26      *         bring the command back to it's state.
27      */
28     Map<String, Object> getData();
29
30     /**
31      * Execute the command represented by this instance. Assumes the instance is already init().
32      * @return A NextCommand containing the next command in chain of commands, or null if chain
33      *         should be terminated. Might return itself (packed in a NextCommand).
34      */
35     NextCommand call();
36
37     default JobType getType() {
38         return JobType.jobTypeOf(this.getClass());
39     }
40
41 }