Merge "Bug 4789 - allowed address pair doesn't have port id"
[ovsdb.git] / openstack / net-virt / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / NeutronL3AdapterEvent.java
1 /*
2  * Copyright (c) 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 package org.opendaylight.ovsdb.openstack.netvirt;
9
10 import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
11 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
13
14 public class NeutronL3AdapterEvent extends AbstractEvent {
15     public enum SubType {
16         SUBTYPE_EXTERNAL_MAC_UPDATE;  // TODO: Add more subtypes as they come here
17
18         public static final int size = HandlerType.values().length;
19     }
20
21     private final SubType subtype;
22
23     private final Long bridgeDpid;
24     private final IpAddress gatewayIpAddress;
25     private final MacAddress macAddress;
26
27     public NeutronL3AdapterEvent(final Long bridgeDpid, final IpAddress gatewayIpAddress, final MacAddress macAddress) {
28         super(HandlerType.NEUTRON_L3_ADAPTER, Action.UPDATE);
29
30         this.subtype = SubType.SUBTYPE_EXTERNAL_MAC_UPDATE;
31         this.bridgeDpid = bridgeDpid;
32         this.gatewayIpAddress = gatewayIpAddress;
33         this.macAddress = macAddress;
34     }
35
36     public SubType getSubType() {
37         return subtype;
38     }
39
40     public Long getBridgeDpid() {
41         return bridgeDpid;
42     }
43     public IpAddress getGatewayIpAddress() {
44         return gatewayIpAddress;
45     }
46     public MacAddress getMacAddress() {
47         return macAddress;
48     }
49
50     @Override
51     public String toString() {
52         return "NeutronL3AdapterEvent [handler=" + super.getHandlerType()
53                 + ", action=" + super.getAction()
54                 + ", subtype=" + subtype
55                 + ", bridgeDpid=" + bridgeDpid
56                 + ", gatewayIpAddress=" + gatewayIpAddress
57                 + ", macAddress=" + macAddress
58                 + "]";
59     }
60
61     @Override
62     public int hashCode() {
63         final int prime = 31;
64         int result = super.hashCode();
65         result = prime * result + ((subtype == null) ? 0 : subtype.hashCode());
66         result = prime * result + ((bridgeDpid == null) ? 0 : bridgeDpid.hashCode());
67         result = prime * result + ((gatewayIpAddress == null) ? 0 : gatewayIpAddress.hashCode());
68         result = prime * result + ((macAddress == null) ? 0 : macAddress.hashCode());
69         return result;
70     }
71
72     @Override
73     public boolean equals(Object obj) {
74         if (this == obj) {
75             return true;
76         }
77         if (obj == null) {
78             return false;
79         }
80         if (getClass() != obj.getClass()) {
81             return false;
82         }
83         if (!super.equals(obj)) {
84             return false;
85         }
86         NeutronL3AdapterEvent other = (NeutronL3AdapterEvent) obj;
87         if (subtype == null) {
88             if (other.subtype != null) {
89                 return false;
90             }
91         } else if (!subtype.equals(other.subtype)) {
92             return false;
93         }
94         if (bridgeDpid == null) {
95             if (other.bridgeDpid != null) {
96                 return false;
97             }
98         } else if (!bridgeDpid.equals(other.bridgeDpid)) {
99             return false;
100         }
101         if (gatewayIpAddress == null) {
102             if (other.gatewayIpAddress != null) {
103                 return false;
104             }
105         } else if (!gatewayIpAddress.equals(other.gatewayIpAddress)) {
106             return false;
107         }
108         if (macAddress == null) {
109             if (other.macAddress != null) {
110                 return false;
111             }
112         } else if (!macAddress.equals(other.macAddress)) {
113             return false;
114         }
115         return true;
116     }
117 }