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