a6da759f7004177e974f0269638c15cbeb327c3a
[ovsdb.git] / neutron / src / main / java / org / opendaylight / ovsdb / neutron / SouthboundEvent.java
1 package org.opendaylight.ovsdb.neutron;
2
3 import org.opendaylight.controller.sal.core.Node;
4 import org.opendaylight.ovsdb.lib.table.internal.Table;
5
6 public class SouthboundEvent {
7     public enum Type { NODE, ROW };
8     public enum Action { ADD, UPDATE, DELETE };
9     private Type type;
10     private Action action;
11     private Node node;
12     private String tableName;
13     private String uuid;
14     private Table<?> row;
15     public SouthboundEvent(Node node, Action action) {
16         super();
17         this.type = Type.NODE;
18         this.action = action;
19         this.node = node;
20     }
21     public SouthboundEvent(Node node, String tableName, String uuid, Table<?> row, Action action) {
22         super();
23         this.type = Type.ROW;
24         this.action = action;
25         this.node = node;
26         this.tableName = tableName;
27         this.uuid = uuid;
28         this.row = row;
29     }
30     public Type getType() {
31         return type;
32     }
33     public Action getAction() {
34         return action;
35     }
36     public Node getNode() {
37         return node;
38     }
39     public String getTableName() {
40         return tableName;
41     }
42     public String getUuid() {
43         return uuid;
44     }
45     public Table<?> getRow() {
46         return row;
47     }
48     @Override
49     public String toString() {
50         return "SouthboundEvent [type=" + type + ", action=" + action + ", node=" + node + ", tableName=" + tableName
51                 + ", uuid=" + uuid + ", row=" + row + "]";
52     }
53     @Override
54     public int hashCode() {
55         final int prime = 31;
56         int result = 1;
57         result = prime * result + ((action == null) ? 0 : action.hashCode());
58         result = prime * result + ((node == null) ? 0 : node.hashCode());
59         result = prime * result + ((tableName == null) ? 0 : tableName.hashCode());
60         result = prime * result + ((type == null) ? 0 : type.hashCode());
61         result = prime * result + ((uuid == null) ? 0 : uuid.hashCode());
62         return result;
63     }
64     @Override
65     public boolean equals(Object obj) {
66         if (this == obj)
67             return true;
68         if (obj == null)
69             return false;
70         if (getClass() != obj.getClass())
71             return false;
72         SouthboundEvent other = (SouthboundEvent) obj;
73         if (action != other.action)
74             return false;
75         if (node == null) {
76             if (other.node != null)
77                 return false;
78         } else if (!node.equals(other.node))
79             return false;
80         if (tableName == null) {
81             if (other.tableName != null)
82                 return false;
83         } else if (!tableName.equals(other.tableName))
84             return false;
85         if (type != other.type)
86             return false;
87         if (uuid == null) {
88             if (other.uuid != null)
89                 return false;
90         } else if (!uuid.equals(other.uuid))
91             return false;
92         return true;
93     }
94 }