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