Code ReOrganization and Re-Architecture changes
[ovsdb.git] / neutron / src / main / java / org / opendaylight / ovsdb / neutron / SouthboundEvent.java
1 /*
2  * Copyright (C) 2013 Red Hat, Inc.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Authors : Madhu Venugopal, Brent Salisbury
9  */
10 package org.opendaylight.ovsdb.neutron;
11
12 import org.opendaylight.controller.sal.core.Node;
13 import org.opendaylight.ovsdb.lib.table.Table;
14
15 public class SouthboundEvent {
16     public enum Type { NODE, ROW };
17     public enum Action { ADD, UPDATE, DELETE };
18     private Type type;
19     private Action action;
20     private Node node;
21     private String tableName;
22     private String uuid;
23     private Table<?> row;
24     public SouthboundEvent(Node node, Action action) {
25         super();
26         this.type = Type.NODE;
27         this.action = action;
28         this.node = node;
29     }
30     public SouthboundEvent(Node node, String tableName, String uuid, Table<?> row, Action action) {
31         super();
32         this.type = Type.ROW;
33         this.action = action;
34         this.node = node;
35         this.tableName = tableName;
36         this.uuid = uuid;
37         this.row = row;
38     }
39     public Type getType() {
40         return type;
41     }
42     public Action getAction() {
43         return action;
44     }
45     public Node getNode() {
46         return node;
47     }
48     public String getTableName() {
49         return tableName;
50     }
51     public String getUuid() {
52         return uuid;
53     }
54     public Table<?> getRow() {
55         return row;
56     }
57     @Override
58     public String toString() {
59         return "SouthboundEvent [type=" + type + ", action=" + action + ", node=" + node + ", tableName=" + tableName
60                 + ", uuid=" + uuid + ", row=" + row + "]";
61     }
62     @Override
63     public int hashCode() {
64         final int prime = 31;
65         int result = 1;
66         result = prime * result + ((action == null) ? 0 : action.hashCode());
67         result = prime * result + ((node == null) ? 0 : node.hashCode());
68         result = prime * result + ((tableName == null) ? 0 : tableName.hashCode());
69         result = prime * result + ((type == null) ? 0 : type.hashCode());
70         result = prime * result + ((uuid == null) ? 0 : uuid.hashCode());
71         return result;
72     }
73     @Override
74     public boolean equals(Object obj) {
75         if (this == obj)
76             return true;
77         if (obj == null)
78             return false;
79         if (getClass() != obj.getClass())
80             return false;
81         SouthboundEvent other = (SouthboundEvent) obj;
82         if (action != other.action)
83             return false;
84         if (node == null) {
85             if (other.node != null)
86                 return false;
87         } else if (!node.equals(other.node))
88             return false;
89         if (tableName == null) {
90             if (other.tableName != null)
91                 return false;
92         } else if (!tableName.equals(other.tableName))
93             return false;
94         if (type != other.type)
95             return false;
96         if (uuid == null) {
97             if (other.uuid != null)
98                 return false;
99         } else if (!uuid.equals(other.uuid))
100             return false;
101         return true;
102     }
103 }