2 * Copyright (c) 2015 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
8 package org.opendaylight.netvirt.vpnmanager;
10 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
12 import java.net.InetAddress;
13 import java.util.concurrent.Delayed;
14 import java.util.concurrent.TimeUnit;
16 public class MacEntry implements Delayed {
18 private long expiryTime;
19 private String vpnName;
20 private MacAddress macAddress;
21 private InetAddress ipAddress;
22 private String interfaceName;
24 public MacEntry(long delay, String vpnName, MacAddress macAddress, InetAddress inetAddress, String interfaceName) {
25 this.expiryTime = System.currentTimeMillis() + delay;
26 this.vpnName = vpnName;
27 this.macAddress = macAddress;
28 this.ipAddress = inetAddress;
29 this.interfaceName = interfaceName;
32 public String getVpnName() {
36 public void setVpnName(String vpnName) {
37 this.vpnName = vpnName;
42 public String toString() {
43 return "MacEntry [expiryTime=" + expiryTime + ", vpnName=" + vpnName + ", macAddress=" + macAddress
44 + ", ipAddress=" + ipAddress + ", interfaceName=" + interfaceName + "]";
47 public MacAddress getMacAddress() {
51 public String getInterfaceName() {
55 public void setInterfaceName(String interfaceName) {
56 this.interfaceName = interfaceName;
59 public InetAddress getIpAddress() {
65 public int compareTo(Delayed obj) {
66 if (this.expiryTime < ((MacEntry) obj).expiryTime) {
68 } else if (this.expiryTime > ((MacEntry) obj).expiryTime) {
76 public long getDelay(TimeUnit arg0) {
77 long diff = expiryTime - System.currentTimeMillis();
78 return arg0.convert(diff, TimeUnit.MILLISECONDS);
82 public int hashCode() {
85 result = prime * result
86 + ((macAddress == null) ? 0 : macAddress.hashCode());
91 public boolean equals(Object obj) {
92 boolean result = false;
93 if (getClass() != obj.getClass())
96 MacEntry other = (MacEntry) obj;
97 result = vpnName.equals(other.vpnName) && macAddress.equals(other.macAddress) && ipAddress.equals(other.ipAddress) && interfaceName.equals(other.interfaceName);