Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 1 | package net.onrc.onos.intent; |
2 | |||||
3 | /** | ||||
4 | * @author Toshio Koide (t-koide@onlab.us) | ||||
5 | */ | ||||
Toshio Koide | b609b3b | 2014-02-14 18:25:52 -0800 | [diff] [blame] | 6 | public class Intent { |
Nick Karanatsios | 88948d3 | 2014-02-18 15:14:30 -0800 | [diff] [blame] | 7 | public enum IntentState { |
Toshio Koide | b609b3b | 2014-02-14 18:25:52 -0800 | [diff] [blame] | 8 | CREATED, |
9 | INST_REQ, | ||||
10 | INST_NACK, | ||||
11 | INST_ACK, | ||||
12 | DEL_REQ, | ||||
13 | DEL_PENDING, | ||||
14 | DEL_ACK, | ||||
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 15 | } |
Toshio Koide | b609b3b | 2014-02-14 18:25:52 -0800 | [diff] [blame] | 16 | |
Toshio Koide | 13986d1 | 2014-02-11 20:25:32 -0800 | [diff] [blame] | 17 | protected String id; |
Toshio Koide | b609b3b | 2014-02-14 18:25:52 -0800 | [diff] [blame] | 18 | protected IntentState state = IntentState.CREATED; |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 19 | |
20 | /** | ||||
21 | * Default constructor for Kryo deserialization | ||||
22 | */ | ||||
Toshio Koide | c406e79 | 2014-02-14 16:52:42 -0800 | [diff] [blame] | 23 | protected Intent() { |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 24 | } |
Toshio Koide | 13986d1 | 2014-02-11 20:25:32 -0800 | [diff] [blame] | 25 | |
26 | public Intent(String id) { | ||||
27 | this.id = id; | ||||
28 | } | ||||
29 | |||||
Toshio Koide | b609b3b | 2014-02-14 18:25:52 -0800 | [diff] [blame] | 30 | public Intent(String id, IntentState state) { |
31 | this.id = id; | ||||
32 | this.state = state; | ||||
33 | } | ||||
34 | |||||
Toshio Koide | 13986d1 | 2014-02-11 20:25:32 -0800 | [diff] [blame] | 35 | public String getId() { |
36 | return id; | ||||
37 | } | ||||
Toshio Koide | b609b3b | 2014-02-14 18:25:52 -0800 | [diff] [blame] | 38 | |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 39 | public IntentState getState() { |
40 | return state; | ||||
41 | } | ||||
Toshio Koide | b609b3b | 2014-02-14 18:25:52 -0800 | [diff] [blame] | 42 | |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 43 | public IntentState setState(IntentState newState) { |
44 | IntentState oldState = state; | ||||
45 | state = newState; | ||||
46 | return oldState; | ||||
47 | } | ||||
Toshio Koide | 4f30873 | 2014-02-18 15:19:48 -0800 | [diff] [blame] | 48 | |
Toshio Koide | 13986d1 | 2014-02-11 20:25:32 -0800 | [diff] [blame] | 49 | @Override |
50 | public int hashCode() { | ||||
51 | return id.hashCode(); | ||||
52 | } | ||||
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 53 | } |