2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
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
9 package org.opendaylight.vpnservice.neutronvpn.api.l2gw;
11 import java.util.ArrayList;
12 import java.util.Collections;
13 import java.util.List;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs;
20 * The Class L2GatewayDevice.
22 public class L2GatewayDevice {
24 /** The device name. */
27 /** The hwvtep node id. */
30 /** The tunnel ips. */
31 List<IpAddress> tunnelIps = new ArrayList<IpAddress>();
33 /** The l2 gateway ids. */
34 List<Uuid> l2GatewayIds = new ArrayList<Uuid>();
36 /** The ucast local macs. */
37 List<LocalUcastMacs> ucastLocalMacs = Collections.synchronizedList(new ArrayList<LocalUcastMacs>());
40 * VTEP device name mentioned with L2 Gateway.
42 * @return the device name
44 public String getDeviceName() {
49 * Sets the device name.
54 public void setDeviceName(String deviceName) {
55 this.deviceName = deviceName;
59 * VTEP Node id for the device mentioned with L2 Gateway.
61 * @return the hwvtep node id
63 public String getHwvtepNodeId() {
68 * Sets the hwvtep node id.
71 * the new hwvtep node id
73 public void setHwvtepNodeId(String nodeId) {
74 this.hwvtepNodeId = nodeId;
78 * Tunnel IP created with in the device mentioned with L2 Gateway.
80 * @return the tunnel ips
82 public List<IpAddress> getTunnelIps() {
89 * @return the tunnel ip
91 public IpAddress getTunnelIp() {
92 if (tunnelIps.size() > 0) {
93 return tunnelIps.get(0);
104 public void addTunnelIp(IpAddress tunnelIp) {
105 tunnelIps.add(tunnelIp);
109 * UUID representing L2Gateway.
111 * @return the l2 gateway ids
113 public List<Uuid> getL2GatewayIds() {
118 * Adds the l2 gateway id.
123 public void addL2GatewayId(Uuid l2GatewayId) {
124 l2GatewayIds.add(l2GatewayId);
128 * Removes the l2 gateway id.
133 public void removeL2GatewayId(Uuid l2GatewayId) {
134 l2GatewayIds.remove(l2GatewayId);
138 * Clear hwvtep node data.
140 public void clearHwvtepNodeData() {
146 * Sets the tunnel ips.
151 public void setTunnelIps(List<IpAddress> tunnelIps) {
152 this.tunnelIps = tunnelIps;
156 * Gets the ucast local macs.
158 * @return the ucast local macs
160 public List<LocalUcastMacs> getUcastLocalMacs() {
161 return new ArrayList<>(ucastLocalMacs);
165 * Adds the ucast local mac.
167 * @param localUcastMacs
168 * the local ucast macs
170 public void addUcastLocalMac(LocalUcastMacs localUcastMacs) {
171 ucastLocalMacs.add(localUcastMacs);
175 * Removes the ucast local mac.
177 * @param localUcastMacs
178 * the local ucast macs
180 public void removeUcastLocalMac(LocalUcastMacs localUcastMacs) {
181 ucastLocalMacs.remove(localUcastMacs);
187 * @see java.lang.Object#hashCode()
190 public int hashCode() {
191 final int prime = 31;
193 result = prime * result + ((deviceName == null) ? 0 : deviceName.hashCode());
194 result = prime * result + ((hwvtepNodeId == null) ? 0 : hwvtepNodeId.hashCode());
195 result = prime * result + ((l2GatewayIds == null) ? 0 : l2GatewayIds.hashCode());
196 result = prime * result + ((tunnelIps == null) ? 0 : tunnelIps.hashCode());
197 result = prime * result + ((ucastLocalMacs == null) ? 0 : ucastLocalMacs.hashCode());
204 * @see java.lang.Object#equals(java.lang.Object)
207 public boolean equals(Object obj) {
214 if (getClass() != obj.getClass()) {
217 L2GatewayDevice other = (L2GatewayDevice) obj;
218 if (deviceName == null) {
219 if (other.deviceName != null) {
222 } else if (!deviceName.equals(other.deviceName)) {
225 if (hwvtepNodeId == null) {
226 if (other.hwvtepNodeId != null) {
229 } else if (!hwvtepNodeId.equals(other.hwvtepNodeId)) {
232 if (l2GatewayIds == null) {
233 if (other.l2GatewayIds != null) {
236 } else if (!l2GatewayIds.equals(other.l2GatewayIds)) {
239 if (tunnelIps == null) {
240 if (other.tunnelIps != null) {
243 } else if (!tunnelIps.equals(other.tunnelIps)) {
246 if (ucastLocalMacs == null) {
247 if (other.ucastLocalMacs != null) {
250 } else if (!ucastLocalMacs.equals(other.ucastLocalMacs)) {
259 * @see java.lang.Object#toString()
262 public String toString() {
263 StringBuilder builder = new StringBuilder();
264 builder.append("L2GatewayDevice [deviceName=").append(deviceName).append(", hwvtepNodeId=").append(hwvtepNodeId)
265 .append(", tunnelIps=").append(tunnelIps).append(", l2GatewayIds=").append(l2GatewayIds)
266 .append(", ucastLocalMacs=").append(ucastLocalMacs).append("]");
267 return builder.toString();