tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net; |
| 2 | |
tom | bb58c20 | 2014-09-07 22:51:50 -0700 | [diff] [blame] | 3 | import java.util.Objects; |
| 4 | |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 5 | /** |
| 6 | * Representation of a network edge location where an end-station host is |
| 7 | * connected. |
| 8 | */ |
tom | bb58c20 | 2014-09-07 22:51:50 -0700 | [diff] [blame] | 9 | public class HostLocation extends ConnectPoint { |
| 10 | |
| 11 | private final long time; |
| 12 | |
| 13 | public HostLocation(DeviceId deviceId, PortNumber portNumber, long time) { |
| 14 | super(deviceId, portNumber); |
| 15 | this.time = time; |
| 16 | } |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 17 | |
| 18 | /** |
| 19 | * Returns the timestamp when the location was established, given in |
| 20 | * milliseconds since start of epoch. |
| 21 | * |
| 22 | * @return timestamp in milliseconds since start of epoch |
| 23 | */ |
tom | bb58c20 | 2014-09-07 22:51:50 -0700 | [diff] [blame] | 24 | public long time() { |
| 25 | return time; |
| 26 | } |
| 27 | |
| 28 | @Override |
| 29 | public int hashCode() { |
| 30 | return 31 * super.hashCode() + Objects.hash(time); |
| 31 | } |
| 32 | |
| 33 | @Override |
| 34 | public boolean equals(Object obj) { |
| 35 | if (obj instanceof HostLocation) { |
| 36 | final HostLocation other = (HostLocation) obj; |
| 37 | return super.equals(obj) && Objects.equals(this.time, other.time); |
| 38 | } |
| 39 | return false; |
| 40 | } |
tom | b36046e | 2014-08-27 00:22:24 -0700 | [diff] [blame] | 41 | |
| 42 | } |