blob: de960f05ed0d66dde5554f8f620bc54cbd0aae4b [file] [log] [blame]
Toshio Koidead17d5e2014-02-11 11:36:02 -08001package net.onrc.onos.intent;
2
3/**
4 * @author Toshio Koide (t-koide@onlab.us)
5 */
Toshio Koideb609b3b2014-02-14 18:25:52 -08006public class Intent {
Toshio Koide0e4d8d22014-02-14 10:56:10 -08007 enum IntentState {
Toshio Koideb609b3b2014-02-14 18:25:52 -08008 CREATED,
9 INST_REQ,
10 INST_NACK,
11 INST_ACK,
12 DEL_REQ,
13 DEL_PENDING,
14 DEL_ACK,
Toshio Koide0e4d8d22014-02-14 10:56:10 -080015 }
Toshio Koideb609b3b2014-02-14 18:25:52 -080016
Toshio Koide13986d12014-02-11 20:25:32 -080017 protected String id;
Toshio Koideb609b3b2014-02-14 18:25:52 -080018 protected IntentState state = IntentState.CREATED;
Toshio Koide0e4d8d22014-02-14 10:56:10 -080019
20 /**
21 * Default constructor for Kryo deserialization
22 */
Toshio Koidec406e792014-02-14 16:52:42 -080023 protected Intent() {
Toshio Koide0e4d8d22014-02-14 10:56:10 -080024 }
Toshio Koide13986d12014-02-11 20:25:32 -080025
26 public Intent(String id) {
27 this.id = id;
28 }
29
Toshio Koideb609b3b2014-02-14 18:25:52 -080030 public Intent(String id, IntentState state) {
31 this.id = id;
32 this.state = state;
33 }
34
Toshio Koide13986d12014-02-11 20:25:32 -080035 public String getId() {
36 return id;
37 }
Toshio Koideb609b3b2014-02-14 18:25:52 -080038
Toshio Koide0e4d8d22014-02-14 10:56:10 -080039 public IntentState getState() {
40 return state;
41 }
Toshio Koideb609b3b2014-02-14 18:25:52 -080042
Toshio Koide0e4d8d22014-02-14 10:56:10 -080043 public IntentState setState(IntentState newState) {
44 IntentState oldState = state;
45 state = newState;
46 return oldState;
47 }
Toshio Koideb609b3b2014-02-14 18:25:52 -080048
Toshio Koide13986d12014-02-11 20:25:32 -080049 @Override
50 public int hashCode() {
51 return id.hashCode();
52 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080053}