blob: 6bbb7461e6efca1dbcc5a53e93da4c270cef91b7 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.topology;
tom2d331412014-09-10 21:31:20 -070017
Brian O'Connorabafb502014-12-02 22:26:20 -080018import org.onosproject.net.DeviceId;
tom2d331412014-09-10 21:31:20 -070019
20import java.util.Objects;
21
22/**
23 * Implementation of the topology vertex backed by a device id.
24 */
tombe988312014-09-19 18:38:47 -070025public class DefaultTopologyVertex implements TopologyVertex {
tom2d331412014-09-10 21:31:20 -070026
27 private final DeviceId deviceId;
28
29 /**
30 * Creates a new topology vertex.
31 *
32 * @param deviceId backing infrastructure device identifier
33 */
tombe988312014-09-19 18:38:47 -070034 public DefaultTopologyVertex(DeviceId deviceId) {
tom2d331412014-09-10 21:31:20 -070035 this.deviceId = deviceId;
36 }
37
38 @Override
39 public DeviceId deviceId() {
40 return deviceId;
41 }
42
43 @Override
44 public int hashCode() {
HIGUCHI Yutaca9cc8e2015-10-29 23:26:51 -070045 return deviceId.hashCode();
tom2d331412014-09-10 21:31:20 -070046 }
47
48 @Override
49 public boolean equals(Object obj) {
tomfc9a4ff2014-09-22 18:22:47 -070050 if (this == obj) {
51 return true;
52 }
tom97937552014-09-11 10:48:42 -070053 if (obj instanceof DefaultTopologyVertex) {
54 final DefaultTopologyVertex other = (DefaultTopologyVertex) obj;
tom2d331412014-09-10 21:31:20 -070055 return Objects.equals(this.deviceId, other.deviceId);
56 }
57 return false;
58 }
59
60 @Override
61 public String toString() {
62 return deviceId.toString();
63 }
64
65}
66