blob: 3227b62eb4b890a9868db0d01541bf442cc7d907 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-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 */
Thomas Vachuskac97aa612015-06-23 16:00:18 -070016package org.onosproject.store.trivial;
tom97937552014-09-11 10:48:42 -070017
Brian O'Connorabafb502014-12-02 22:26:20 -080018import org.onosproject.net.DeviceId;
tom97937552014-09-11 10:48:42 -070019
20import java.util.Objects;
21
22/**
tom578ebdc2014-09-11 11:12:51 -070023 * Key for filing pre-computed paths between source and destination devices.
tom97937552014-09-11 10:48:42 -070024 */
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) {
tomfc9a4ff2014-09-22 18:22:47 -070046 if (this == obj) {
47 return true;
48 }
tom97937552014-09-11 10:48:42 -070049 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}