tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame^] | 1 | package org.onlab.onos.net.topology; |
tom | 2d33141 | 2014-09-10 21:31:20 -0700 | [diff] [blame] | 2 | |
| 3 | import org.onlab.onos.net.DeviceId; |
tom | 2d33141 | 2014-09-10 21:31:20 -0700 | [diff] [blame] | 4 | |
| 5 | import java.util.Objects; |
| 6 | |
| 7 | /** |
| 8 | * Implementation of the topology vertex backed by a device id. |
| 9 | */ |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame^] | 10 | public class DefaultTopologyVertex implements TopologyVertex { |
tom | 2d33141 | 2014-09-10 21:31:20 -0700 | [diff] [blame] | 11 | |
| 12 | private final DeviceId deviceId; |
| 13 | |
| 14 | /** |
| 15 | * Creates a new topology vertex. |
| 16 | * |
| 17 | * @param deviceId backing infrastructure device identifier |
| 18 | */ |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame^] | 19 | public DefaultTopologyVertex(DeviceId deviceId) { |
tom | 2d33141 | 2014-09-10 21:31:20 -0700 | [diff] [blame] | 20 | this.deviceId = deviceId; |
| 21 | } |
| 22 | |
| 23 | @Override |
| 24 | public DeviceId deviceId() { |
| 25 | return deviceId; |
| 26 | } |
| 27 | |
| 28 | @Override |
| 29 | public int hashCode() { |
| 30 | return Objects.hash(deviceId); |
| 31 | } |
| 32 | |
| 33 | @Override |
| 34 | public boolean equals(Object obj) { |
tom | 9793755 | 2014-09-11 10:48:42 -0700 | [diff] [blame] | 35 | if (obj instanceof DefaultTopologyVertex) { |
| 36 | final DefaultTopologyVertex other = (DefaultTopologyVertex) obj; |
tom | 2d33141 | 2014-09-10 21:31:20 -0700 | [diff] [blame] | 37 | return Objects.equals(this.deviceId, other.deviceId); |
| 38 | } |
| 39 | return false; |
| 40 | } |
| 41 | |
| 42 | @Override |
| 43 | public String toString() { |
| 44 | return deviceId.toString(); |
| 45 | } |
| 46 | |
| 47 | } |
| 48 | |