Ovsdb plugin compatibility layer
[netvirt.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.neutron.spi.NeutronFloatingIP;
14 import org.opendaylight.neutron.spi.NeutronLoadBalancer;
15 import org.opendaylight.neutron.spi.NeutronLoadBalancerPool;
16 import org.opendaylight.neutron.spi.NeutronLoadBalancerPoolMember;
17 import org.opendaylight.neutron.spi.NeutronNetwork;
18 import org.opendaylight.neutron.spi.NeutronPort;
19 import org.opendaylight.neutron.spi.NeutronRouter;
20 import org.opendaylight.neutron.spi.NeutronRouter_Interface;
21 import org.opendaylight.neutron.spi.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         }
143         if (obj == null) {
144             return false;
145         }
146         if (getClass() != obj.getClass()) {
147             return false;
148         }
149         if (!super.equals(obj)) {
150             return false;
151         }
152         NorthboundEvent other = (NorthboundEvent) obj;
153         if (port == null) {
154             if (other.port != null) {
155                 return false;
156             }
157         } else if (!port.equals(other.port)) {
158             return false;
159         }
160         if (subnet == null) {
161             if (other.subnet != null) {
162                 return false;
163             }
164         } else if (!subnet.equals(other.subnet)) {
165             return false;
166         }
167         if (router == null) {
168             if (other.router != null) {
169                 return false;
170             }
171         } else if (!router.equals(other.router)) {
172             return false;
173         }
174         if (routerInterface == null) {
175             if (other.routerInterface != null) {
176                 return false;
177             }
178         } else if (!routerInterface.equals(other.routerInterface)) {
179             return false;
180         }
181         if (neutronFloatingIP == null) {
182             if (other.neutronFloatingIP != null) {
183                 return false;
184             }
185         } else if (!neutronFloatingIP.equals(other.neutronFloatingIP)) {
186             return false;
187         }
188         if (neutronNetwork == null) {
189             if (other.neutronNetwork != null) {
190                 return false;
191             }
192         } else if (!neutronNetwork.equals(other.neutronNetwork)) {
193             return false;
194         }
195         if (loadBalancer == null) {
196             if (other.loadBalancer != null) {
197                 return false;
198             }
199         } else if (!loadBalancer.equals(other.loadBalancer)) {
200             return false;
201         }
202         if (loadBalancerPool == null) {
203             if (other.loadBalancerPool != null) {
204                 return false;
205             }
206         } else if (!loadBalancerPool.equals(other.loadBalancerPool)) {
207             return false;
208         }
209         if (loadBalancerPoolMember == null) {
210             if (other.loadBalancerPoolMember != null) {
211                 return false;
212             }
213         } else if (!loadBalancerPoolMember.equals(other.loadBalancerPoolMember)) {
214             return false;
215         }
216         return true;
217     }
218 }