Refactor OVSDB Neutron Code
[ovsdb.git] / openstack / net-virt / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / 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.openstack.netvirt;
11
12 import org.opendaylight.controller.sal.core.Node;
13 import org.opendaylight.ovsdb.lib.notation.Row;
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 Row row;
24     private Object context;
25     public SouthboundEvent(Node node, Action action) {
26         super();
27         this.type = Type.NODE;
28         this.action = action;
29         this.node = node;
30     }
31     public SouthboundEvent(Node node, String tableName, String uuid, Row row, Action action) {
32         super();
33         this.type = Type.ROW;
34         this.action = action;
35         this.node = node;
36         this.tableName = tableName;
37         this.uuid = uuid;
38         this.row = row;
39     }
40     public SouthboundEvent(Node node, String tableName, String uuid, Row row, Object context, Action action) {
41         super();
42         this.type = Type.ROW;
43         this.action = action;
44         this.node = node;
45         this.tableName = tableName;
46         this.uuid = uuid;
47         this.row = row;
48         this.context = context;
49     }
50     public Type getType() {
51         return type;
52     }
53     public Action getAction() {
54         return action;
55     }
56     public Node getNode() {
57         return node;
58     }
59     public String getTableName() {
60         return tableName;
61     }
62     public String getUuid() {
63         return uuid;
64     }
65     public Row getRow() {
66         return row;
67     }
68     public Object getContext() {
69         return context;
70     }
71     @Override
72     public String toString() {
73         return "SouthboundEvent [type=" + type + ", action=" + action + ", node=" + node + ", tableName=" + tableName
74                 + ", uuid=" + uuid + ", row=" + row + ", context=" + context.toString() + "]";
75     }
76     @Override
77     public int hashCode() {
78         final int prime = 31;
79         int result = 1;
80         result = prime * result + ((action == null) ? 0 : action.hashCode());
81         result = prime * result + ((node == null) ? 0 : node.hashCode());
82         result = prime * result + ((tableName == null) ? 0 : tableName.hashCode());
83         result = prime * result + ((type == null) ? 0 : type.hashCode());
84         result = prime * result + ((uuid == null) ? 0 : uuid.hashCode());
85         return result;
86     }
87     @Override
88     public boolean equals(Object obj) {
89         if (this == obj)
90             return true;
91         if (obj == null)
92             return false;
93         if (getClass() != obj.getClass())
94             return false;
95         SouthboundEvent other = (SouthboundEvent) obj;
96         if (action != other.action)
97             return false;
98         if (node == null) {
99             if (other.node != null)
100                 return false;
101         } else if (!node.equals(other.node))
102             return false;
103         if (tableName == null) {
104             if (other.tableName != null)
105                 return false;
106         } else if (!tableName.equals(other.tableName))
107             return false;
108         if (type != other.type)
109             return false;
110         if (uuid == null) {
111             if (other.uuid != null)
112                 return false;
113         } else if (!uuid.equals(other.uuid))
114             return false;
115         return true;
116     }
117 }