Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
Thomas Vachuska | c97aa61 | 2015-06-23 16:00:18 -0700 | [diff] [blame] | 16 | package org.onosproject.store.trivial; |
tom | 9793755 | 2014-09-11 10:48:42 -0700 | [diff] [blame] | 17 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 18 | import org.onosproject.net.DeviceId; |
tom | 9793755 | 2014-09-11 10:48:42 -0700 | [diff] [blame] | 19 | |
| 20 | import java.util.Objects; |
| 21 | |
| 22 | /** |
tom | 578ebdc | 2014-09-11 11:12:51 -0700 | [diff] [blame] | 23 | * Key for filing pre-computed paths between source and destination devices. |
tom | 9793755 | 2014-09-11 10:48:42 -0700 | [diff] [blame] | 24 | */ |
| 25 | class 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) { |
tom | fc9a4ff | 2014-09-22 18:22:47 -0700 | [diff] [blame] | 46 | if (this == obj) { |
| 47 | return true; |
| 48 | } |
tom | 9793755 | 2014-09-11 10:48:42 -0700 | [diff] [blame] | 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 | } |