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