blob: 4337f581a04664628e053b0cbc1240e5a058dc13 [file] [log] [blame]
tombe988312014-09-19 18:38:47 -07001package org.onlab.onos.net.topology;
tom2d331412014-09-10 21:31:20 -07002
3import org.onlab.onos.net.DeviceId;
tom2d331412014-09-10 21:31:20 -07004
5import java.util.Objects;
6
7/**
8 * Implementation of the topology vertex backed by a device id.
9 */
tombe988312014-09-19 18:38:47 -070010public class DefaultTopologyVertex implements TopologyVertex {
tom2d331412014-09-10 21:31:20 -070011
12 private final DeviceId deviceId;
13
14 /**
15 * Creates a new topology vertex.
16 *
17 * @param deviceId backing infrastructure device identifier
18 */
tombe988312014-09-19 18:38:47 -070019 public DefaultTopologyVertex(DeviceId deviceId) {
tom2d331412014-09-10 21:31:20 -070020 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) {
tomfc9a4ff2014-09-22 18:22:47 -070035 if (this == obj) {
36 return true;
37 }
tom97937552014-09-11 10:48:42 -070038 if (obj instanceof DefaultTopologyVertex) {
39 final DefaultTopologyVertex other = (DefaultTopologyVertex) obj;
tom2d331412014-09-10 21:31:20 -070040 return Objects.equals(this.deviceId, other.deviceId);
41 }
42 return false;
43 }
44
45 @Override
46 public String toString() {
47 return deviceId.toString();
48 }
49
50}
51