blob: 9a403252e96198034e1f95f3eddb49451c1ce7e0 [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 Koided9fa2a82014-02-19 17:35:18 -08006public class Intent {
Nick Karanatsios88948d32014-02-18 15:14:30 -08007 public 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 Koidea10c0372014-02-20 17:28:10 -080015 REROUTE_REQ,
Toshio Koide0e4d8d22014-02-14 10:56:10 -080016 }
Toshio Koideb609b3b2014-02-14 18:25:52 -080017
Toshio Koidea10c0372014-02-20 17:28:10 -080018 private String id;
19 private IntentState state = IntentState.CREATED;
Toshio Koide0e4d8d22014-02-14 10:56:10 -080020
21 /**
22 * Default constructor for Kryo deserialization
23 */
Toshio Koidec406e792014-02-14 16:52:42 -080024 protected Intent() {
Toshio Koide0e4d8d22014-02-14 10:56:10 -080025 }
Toshio Koide13986d12014-02-11 20:25:32 -080026
27 public Intent(String id) {
28 this.id = id;
29 }
30
Toshio Koideb609b3b2014-02-14 18:25:52 -080031 public Intent(String id, IntentState state) {
32 this.id = id;
33 this.state = state;
34 }
35
Toshio Koide13986d12014-02-11 20:25:32 -080036 public String getId() {
37 return id;
38 }
Toshio Koideb609b3b2014-02-14 18:25:52 -080039
Toshio Koide0e4d8d22014-02-14 10:56:10 -080040 public IntentState getState() {
41 return state;
42 }
Toshio Koideb609b3b2014-02-14 18:25:52 -080043
Toshio Koide0e4d8d22014-02-14 10:56:10 -080044 public IntentState setState(IntentState newState) {
45 IntentState oldState = state;
46 state = newState;
47 return oldState;
48 }
Toshio Koide4f308732014-02-18 15:19:48 -080049
Toshio Koide13986d12014-02-11 20:25:32 -080050 @Override
51 public int hashCode() {
Toshio Koidea10c0372014-02-20 17:28:10 -080052 return (id == null) ? 0 : id.hashCode();
53 }
54
55 @Override
56 public boolean equals(Object obj) {
57 if (this == obj)
58 return true;
59 if ((obj == null) || (getClass() != obj.getClass()))
60 return false;
61 Intent other = (Intent) obj;
62 if (id == null) {
63 if (other.id != null)
64 return false;
65 } else if (!id.equals(other.id))
66 return false;
67 return true;
Toshio Koide13986d12014-02-11 20:25:32 -080068 }
Toshio Koided9fa2a82014-02-19 17:35:18 -080069
Toshio Koide0c9106d2014-02-19 15:26:38 -080070 @Override
71 public String toString() {
72 return id.toString() + ", " + state.toString();
73 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080074}