blob: 8b71a13aef6abbc6e565f122399d4946633fef58 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
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 */
alshabib339a3d92014-09-26 17:54:32 -070016package org.onlab.onos.store.topology.impl;
17
18import org.onlab.onos.net.DeviceId;
19
20import java.util.Objects;
21
22/**
23 * Key for filing pre-computed paths between source and destination devices.
24 */
25class PathKey {
26 private final DeviceId src;
27 private final DeviceId dst;
28
29 /**
30 * Creates a path key from the given source/dest pair.
31 * @param src source device
32 * @param dst destination device
33 */
34 PathKey(DeviceId src, DeviceId dst) {
35 this.src = src;
36 this.dst = dst;
37 }
38
39 @Override
40 public int hashCode() {
41 return Objects.hash(src, dst);
42 }
43
44 @Override
45 public boolean equals(Object obj) {
46 if (this == obj) {
47 return true;
48 }
49 if (obj instanceof PathKey) {
50 final PathKey other = (PathKey) obj;
51 return Objects.equals(this.src, other.src) && Objects.equals(this.dst, other.dst);
52 }
53 return false;
54 }
55}