More southbound migration for netvirt
[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.ovsdb.lib.notation.Row;
13 import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
14 //import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
17 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
18
19 public class SouthboundEvent extends AbstractEvent {
20     public enum Type { NODE, ROW, OPENVSWITCH, BRIDGE, PORT }
21     private Type type;
22     private Node node;
23     private String tableName;
24     private String uuid;
25     private Row row;
26     private Object context;
27     private OvsdbBridgeAugmentation bridge;
28     private OvsdbTerminationPointAugmentation port;
29     private String portName;
30     public SouthboundEvent(Node node, Action action) {
31         super(HandlerType.SOUTHBOUND, action);
32         this.type = Type.NODE;
33         this.node = node;
34     }
35     public SouthboundEvent(Node node, String tableName, String uuid, Row row, Action action) {
36         super(HandlerType.SOUTHBOUND, action);
37         this.type = Type.ROW;
38         this.node = node;
39         this.tableName = tableName;
40         this.uuid = uuid;
41         this.row = row;
42     }
43     public SouthboundEvent(Node node, String tableName, String uuid, Row row, Object context, Action action) {
44         super(HandlerType.SOUTHBOUND, action);
45         this.type = Type.ROW;
46         this.node = node;
47         this.tableName = tableName;
48         this.uuid = uuid;
49         this.row = row;
50         this.context = context;
51     }
52     public SouthboundEvent(Node node, OvsdbBridgeAugmentation bridge, Action action) {
53         super(HandlerType.SOUTHBOUND, action);
54         this.type = Type.BRIDGE;
55         this.node = node;
56         this.bridge = bridge;
57     }
58     public SouthboundEvent(Node node, OvsdbTerminationPointAugmentation port, String portName, Action action) {
59         super(HandlerType.SOUTHBOUND, action);
60         this.type = Type.PORT;
61         this.node = node;
62         this.port = port;
63         this.portName = portName;
64     }
65
66     public Type getType() {
67         return type;
68     }
69     public Node getNode() {
70         return node;
71     }
72     public String getTableName() {
73         return tableName;
74     }
75     public String getUuid() {
76         return uuid;
77     }
78     public Row getRow() {
79         return row;
80     }
81     public Object getContext() {
82         return context;
83     }
84     public OvsdbBridgeAugmentation getBridge() {
85         return bridge;
86     }
87     public OvsdbTerminationPointAugmentation getPort() {
88         return port;
89     }
90     public String getPortName() {
91         return portName;
92     }
93     @Override
94     public String toString() {
95         if (type == Type.NODE) {
96             return "SouthboundEvent [type=" + type
97                     + ", action=" + super.getAction()
98                     + ", node=" + node + "]";
99         } else if (type == Type.ROW) {
100             return "SouthboundEvent [type=" + type
101                     + ", action=" + super.getAction()
102                     + ", node=" + node
103                     + ", tableName=" + tableName
104                     + ", uuid=" + uuid
105                     + ", row=" + row
106                     + ", context=" + context + "]";
107         } else {
108             return "SouthboundEvent [type=" + type + "]";
109         }
110     }
111
112     @Override
113     public int hashCode() {
114         final int prime = 31;
115         int result = super.hashCode();
116         result = prime * result + ((node == null) ? 0 : node.hashCode());
117         result = prime * result + ((tableName == null) ? 0 : tableName.hashCode());
118         result = prime * result + ((type == null) ? 0 : type.hashCode());
119         result = prime * result + ((uuid == null) ? 0 : uuid.hashCode());
120         return result;
121     }
122     @Override
123     public boolean equals(Object obj) {
124         if (this == obj) {
125             return true;
126         }
127         if (obj == null) {
128             return false;
129         }
130         if (getClass() != obj.getClass()) {
131             return false;
132         }
133         if (!super.equals(obj)) {
134             return false;
135         }
136         SouthboundEvent other = (SouthboundEvent) obj;
137         if (node == null) {
138             if (other.node != null) {
139                 return false;
140             }
141         } else if (!node.equals(other.node)) {
142             return false;
143         }
144         if (tableName == null) {
145             if (other.tableName != null) {
146                 return false;
147             }
148         } else if (!tableName.equals(other.tableName)) {
149             return false;
150         }
151         if (type == null) {
152             if (other.type != null) {
153                 return false;
154             }
155         } else if (!type.equals(other.type)) {
156             return false;
157         }
158         if (uuid == null) {
159             if (other.uuid != null) {
160                 return false;
161             }
162         } else if (!uuid.equals(other.uuid)) {
163             return false;
164         }
165         return true;
166     }
167 }