L3 Neutron plumbing
[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.NeutronNetwork;
15 import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
16 import org.opendaylight.controller.networkconfig.neutron.NeutronRouter;
17 import org.opendaylight.controller.networkconfig.neutron.NeutronRouter_Interface;
18 import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
19
20 public class NorthboundEvent extends AbstractEvent {
21
22     private NeutronPort port;
23     private NeutronSubnet subnet;
24     private NeutronRouter router;
25     private NeutronRouter_Interface routerInterface;
26     private NeutronFloatingIP neutronFloatingIP;
27     private NeutronNetwork neutronNetwork;
28
29     NorthboundEvent(NeutronPort port, Action action) {
30         super(HandlerType.NEUTRON_PORT, action);
31         this.port = port;
32     }
33
34     NorthboundEvent(NeutronSubnet subnet, Action action) {
35         super(HandlerType.NEUTRON_SUBNET, action);
36         this.subnet = subnet;
37     }
38
39     NorthboundEvent(NeutronRouter router, Action action) {
40         super(HandlerType.NEUTRON_ROUTER, action);
41         this.router = router;
42     }
43
44     NorthboundEvent(NeutronRouter router, NeutronRouter_Interface routerInterface, Action action) {
45         super(HandlerType.NEUTRON_ROUTER, action);
46         this.router = router;
47         this.routerInterface = routerInterface;
48     }
49
50     NorthboundEvent(NeutronFloatingIP neutronFloatingIP, Action action) {
51         super(HandlerType.NEUTRON_FLOATING_IP, action);
52         this.neutronFloatingIP = neutronFloatingIP;
53     }
54
55     NorthboundEvent(NeutronNetwork neutronNetwork, Action action) {
56         super(HandlerType.NEUTRON_NETWORK, action);
57         this.neutronNetwork = neutronNetwork;
58     }
59
60     public NeutronPort getPort() {
61         return port;
62     }
63     public NeutronSubnet getSubnet() {
64         return subnet;
65     }
66     public NeutronRouter getRouter() {
67         return router;
68     }
69     public NeutronRouter_Interface getRouterInterface() {
70         return routerInterface;
71     }
72     public NeutronFloatingIP getNeutronFloatingIP() {
73         return neutronFloatingIP;
74     }
75     public NeutronNetwork getNeutronNetwork() {
76         return neutronNetwork;
77     }
78
79     @Override
80     public String toString() {
81         return "NorthboundEvent [action=" + super.getAction()
82                + ", port=" + port
83                + ", subnet=" + subnet
84                + ", router=" + router
85                + ", routerInterface=" + routerInterface
86                + ", floatingIP=" + neutronFloatingIP
87                + ", network=" + neutronNetwork
88                + "]";
89     }
90
91     @Override
92     public int hashCode() {
93         final int prime = 31;
94         int result = super.hashCode();
95         result = prime * result + ((port == null) ? 0 : port.hashCode());
96         result = prime * result + ((subnet == null) ? 0 : subnet.hashCode());
97         result = prime * result + ((router == null) ? 0 : router.hashCode());
98         result = prime * result + ((routerInterface == null) ? 0 : routerInterface.hashCode());
99         result = prime * result + ((neutronFloatingIP == null) ? 0 : neutronFloatingIP.hashCode());
100         result = prime * result + ((neutronNetwork == null) ? 0 : neutronNetwork.hashCode());
101         return result;
102     }
103
104     @Override
105     public boolean equals(Object obj) {
106         if (this == obj)
107             return true;
108         if (obj == null)
109             return false;
110         if (getClass() != obj.getClass())
111             return false;
112         if (!super.equals(obj))
113             return false;
114         NorthboundEvent other = (NorthboundEvent) obj;
115         if (port == null) {
116             if (other.port != null)
117                 return false;
118         } else if (!port.equals(other.port))
119             return false;
120         if (subnet == null) {
121             if (other.subnet != null)
122                 return false;
123         } else if (!subnet.equals(other.subnet))
124             return false;
125         if (router == null) {
126             if (other.router != null)
127                 return false;
128         } else if (!router.equals(other.router))
129             return false;
130         if (routerInterface == null) {
131             if (other.routerInterface != null)
132                 return false;
133         } else if (!routerInterface.equals(other.routerInterface))
134             return false;
135         if (neutronFloatingIP == null) {
136             if (other.neutronFloatingIP != null)
137                 return false;
138         } else if (!neutronFloatingIP.equals(other.neutronFloatingIP))
139             return false;
140         if (neutronNetwork == null) {
141             if (other.neutronNetwork != null)
142                 return false;
143         } else if (!neutronNetwork.equals(other.neutronNetwork))
144             return false;
145         return true;
146     }
147 }