blob: 043e36472568f70ff830ad7a2130f81fa0fda963 [file] [log] [blame]
tom97937552014-09-11 10:48:42 -07001package org.onlab.onos.net.trivial.topology.impl;
tom2d331412014-09-10 21:31:20 -07002
3import org.onlab.onos.net.DeviceId;
tom97937552014-09-11 10:48:42 -07004import org.onlab.onos.net.topology.TopologyVertex;
tom2d331412014-09-10 21:31:20 -07005
6import java.util.Objects;
7
8/**
9 * Implementation of the topology vertex backed by a device id.
10 */
tom97937552014-09-11 10:48:42 -070011class DefaultTopologyVertex implements TopologyVertex {
tom2d331412014-09-10 21:31:20 -070012
13 private final DeviceId deviceId;
14
15 /**
16 * Creates a new topology vertex.
17 *
18 * @param deviceId backing infrastructure device identifier
19 */
tom97937552014-09-11 10:48:42 -070020 DefaultTopologyVertex(DeviceId deviceId) {
tom2d331412014-09-10 21:31:20 -070021 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) {
tom97937552014-09-11 10:48:42 -070036 if (obj instanceof DefaultTopologyVertex) {
37 final DefaultTopologyVertex other = (DefaultTopologyVertex) obj;
tom2d331412014-09-10 21:31:20 -070038 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