Use Topology Node in place of Inventory Node
[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.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
16
17 public class SouthboundEvent extends AbstractEvent {
18     public enum Type { NODE, ROW }
19     private Type type;
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(HandlerType.SOUTHBOUND, action);
27         this.type = Type.NODE;
28         this.node = node;
29     }
30     public SouthboundEvent(Node node, String tableName, String uuid, Row row, Action action) {
31         super(HandlerType.SOUTHBOUND, action);
32         this.type = Type.ROW;
33         this.node = node;
34         this.tableName = tableName;
35         this.uuid = uuid;
36         this.row = row;
37     }
38     public SouthboundEvent(Node node, String tableName, String uuid, Row row, Object context, Action action) {
39         super(HandlerType.SOUTHBOUND, action);
40         this.type = Type.ROW;
41         this.node = node;
42         this.tableName = tableName;
43         this.uuid = uuid;
44         this.row = row;
45         this.context = context;
46     }
47     public Type getType() {
48         return type;
49     }
50     public Node getNode() {
51         return node;
52     }
53     public String getTableName() {
54         return tableName;
55     }
56     public String getUuid() {
57         return uuid;
58     }
59     public Row getRow() {
60         return row;
61     }
62     public Object getContext() {
63         return context;
64     }
65     @Override
66     public String toString() {
67         if (type == Type.NODE) {
68             return "SouthboundEvent [type=" + type
69                     + ", action=" + super.getAction()
70                     + ", node=" + node + "]";
71         } else if (type == Type.ROW) {
72             return "SouthboundEvent [type=" + type
73                     + ", action=" + super.getAction()
74                     + ", node=" + node
75                     + ", tableName=" + tableName
76                     + ", uuid=" + uuid
77                     + ", row=" + row
78                     + ", context=" + context + "]";
79         } else {
80             return "SouthboundEvent [type=" + type + "]";
81         }
82     }
83
84     @Override
85     public int hashCode() {
86         final int prime = 31;
87         int result = super.hashCode();
88         result = prime * result + ((node == null) ? 0 : node.hashCode());
89         result = prime * result + ((tableName == null) ? 0 : tableName.hashCode());
90         result = prime * result + ((type == null) ? 0 : type.hashCode());
91         result = prime * result + ((uuid == null) ? 0 : uuid.hashCode());
92         return result;
93     }
94     @Override
95     public boolean equals(Object obj) {
96         if (this == obj) {
97             return true;
98         }
99         if (obj == null) {
100             return false;
101         }
102         if (getClass() != obj.getClass()) {
103             return false;
104         }
105         if (!super.equals(obj)) {
106             return false;
107         }
108         SouthboundEvent other = (SouthboundEvent) obj;
109         if (node == null) {
110             if (other.node != null) {
111                 return false;
112             }
113         } else if (!node.equals(other.node)) {
114             return false;
115         }
116         if (tableName == null) {
117             if (other.tableName != null) {
118                 return false;
119             }
120         } else if (!tableName.equals(other.tableName)) {
121             return false;
122         }
123         if (type == null) {
124             if (other.type != null) {
125                 return false;
126             }
127         } else if (!type.equals(other.type)) {
128             return false;
129         }
130         if (uuid == null) {
131             if (other.uuid != null) {
132                 return false;
133             }
134         } else if (!uuid.equals(other.uuid)) {
135             return false;
136         }
137         return true;
138     }
139 }