Fixing Bug 1900 and 1908
[ovsdb.git] / openstack / net-virt / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / NorthboundEvent.java
1 /*
2  * Copyright (C) 2014 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 : Dave Tucker, Flavio Fernandes
9  */
10
11 package org.opendaylight.ovsdb.openstack.netvirt;
12
13 import org.opendaylight.controller.networkconfig.neutron.NeutronFloatingIP;
14 import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancer;
15 import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPool;
16 import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerPoolMember;
17 import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
18 import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
19 import org.opendaylight.controller.networkconfig.neutron.NeutronRouter;
20 import org.opendaylight.controller.networkconfig.neutron.NeutronRouter_Interface;
21 import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
22 import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
23
24 public class NorthboundEvent extends AbstractEvent {
25
26     private NeutronPort port;
27     private NeutronSubnet subnet;
28     private NeutronRouter router;
29     private NeutronRouter_Interface routerInterface;
30     private NeutronFloatingIP neutronFloatingIP;
31     private NeutronNetwork neutronNetwork;
32     private NeutronLoadBalancer loadBalancer;
33     private NeutronLoadBalancerPool loadBalancerPool;
34     private NeutronLoadBalancerPoolMember loadBalancerPoolMember;
35
36     NorthboundEvent(NeutronPort port, Action action) {
37         super(HandlerType.NEUTRON_PORT, action);
38         this.port = port;
39     }
40
41     NorthboundEvent(NeutronSubnet subnet, Action action) {
42         super(HandlerType.NEUTRON_SUBNET, action);
43         this.subnet = subnet;
44     }
45
46     NorthboundEvent(NeutronRouter router, Action action) {
47         super(HandlerType.NEUTRON_ROUTER, action);
48         this.router = router;
49     }
50
51     NorthboundEvent(NeutronRouter router, NeutronRouter_Interface routerInterface, Action action) {
52         super(HandlerType.NEUTRON_ROUTER, action);
53         this.router = router;
54         this.routerInterface = routerInterface;
55     }
56
57     NorthboundEvent(NeutronFloatingIP neutronFloatingIP, Action action) {
58         super(HandlerType.NEUTRON_FLOATING_IP, action);
59         this.neutronFloatingIP = neutronFloatingIP;
60     }
61
62     NorthboundEvent(NeutronNetwork neutronNetwork, Action action) {
63         super(HandlerType.NEUTRON_NETWORK, action);
64         this.neutronNetwork = neutronNetwork;
65     }
66
67     NorthboundEvent(NeutronLoadBalancer loadBalancer, Action action) {
68         super(HandlerType.NEUTRON_LOAD_BALANCER, action);
69         this.loadBalancer = loadBalancer;
70     }
71
72     NorthboundEvent(NeutronLoadBalancerPool loadBalancerPool, Action action) {
73         super(HandlerType.NEUTRON_LOAD_BALANCER_POOL, action);
74         this.loadBalancerPool = loadBalancerPool;
75     }
76
77     NorthboundEvent(NeutronLoadBalancerPoolMember loadBalancerPoolMember, Action action) {
78         super(HandlerType.NEUTRON_LOAD_BALANCER_POOL_MEMBER, action);
79         this.loadBalancerPoolMember = loadBalancerPoolMember;
80     }
81
82     public NeutronPort getPort() {
83         return port;
84     }
85     public NeutronSubnet getSubnet() {
86         return subnet;
87     }
88     public NeutronRouter getRouter() {
89         return router;
90     }
91     public NeutronRouter_Interface getRouterInterface() {
92         return routerInterface;
93     }
94     public NeutronFloatingIP getNeutronFloatingIP() {
95         return neutronFloatingIP;
96     }
97     public NeutronNetwork getNeutronNetwork() {
98         return neutronNetwork;
99     }
100     public NeutronLoadBalancer getLoadBalancer() {
101         return loadBalancer;
102     }
103     public NeutronLoadBalancerPool getLoadBalancerPool() {
104         return loadBalancerPool;
105     }
106     public NeutronLoadBalancerPoolMember getLoadBalancerPoolMember() {
107         return loadBalancerPoolMember;
108     }
109
110     @Override
111     public String toString() {
112         return "NorthboundEvent [action=" + super.getAction()
113                + ", port=" + port
114                + ", subnet=" + subnet
115                + ", router=" + router
116                + ", routerInterface=" + routerInterface
117                + ", floatingIP=" + neutronFloatingIP
118                + ", network=" + neutronNetwork
119                + ", loadBalancer=" + loadBalancer
120                + ", loadBalancerPool=" + loadBalancerPool
121                + ", loadBalancerPoolMember=" + loadBalancerPoolMember
122                + "]";
123     }
124
125     @Override
126     public int hashCode() {
127         final int prime = 31;
128         int result = super.hashCode();
129         result = prime * result + ((port == null) ? 0 : port.hashCode());
130         result = prime * result + ((subnet == null) ? 0 : subnet.hashCode());
131         result = prime * result + ((router == null) ? 0 : router.hashCode());
132         result = prime * result + ((routerInterface == null) ? 0 : routerInterface.hashCode());
133         result = prime * result + ((neutronFloatingIP == null) ? 0 : neutronFloatingIP.hashCode());
134         result = prime * result + ((neutronNetwork == null) ? 0 : neutronNetwork.hashCode());
135         return result;
136     }
137
138     @Override
139     public boolean equals(Object obj) {
140         if (this == obj)
141             return true;
142         if (obj == null)
143             return false;
144         if (getClass() != obj.getClass())
145             return false;
146         if (!super.equals(obj))
147             return false;
148         NorthboundEvent other = (NorthboundEvent) obj;
149         if (port == null) {
150             if (other.port != null)
151                 return false;
152         } else if (!port.equals(other.port))
153             return false;
154         if (subnet == null) {
155             if (other.subnet != null)
156                 return false;
157         } else if (!subnet.equals(other.subnet))
158             return false;
159         if (router == null) {
160             if (other.router != null)
161                 return false;
162         } else if (!router.equals(other.router))
163             return false;
164         if (routerInterface == null) {
165             if (other.routerInterface != null)
166                 return false;
167         } else if (!routerInterface.equals(other.routerInterface))
168             return false;
169         if (neutronFloatingIP == null) {
170             if (other.neutronFloatingIP != null)
171                 return false;
172         } else if (!neutronFloatingIP.equals(other.neutronFloatingIP))
173             return false;
174         if (neutronNetwork == null) {
175             if (other.neutronNetwork != null)
176                 return false;
177         } else if (!neutronNetwork.equals(other.neutronNetwork))
178             return false;
179         if (loadBalancer == null) {
180             if (other.loadBalancer != null)
181                 return false;
182         } else if (!loadBalancer.equals(other.loadBalancer))
183             return false;
184         if (loadBalancerPool == null) {
185             if (other.loadBalancerPool != null)
186                 return false;
187         } else if (!loadBalancerPool.equals(other.loadBalancerPool))
188             return false;
189         if (loadBalancerPoolMember == null) {
190             if (other.loadBalancerPoolMember != null)
191                 return false;
192         } else if (!loadBalancerPoolMember.equals(other.loadBalancerPoolMember))
193             return false;
194         return true;
195     }
196 }