Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 1 | /* |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 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 | */ |
| 16 | |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 17 | package org.onosproject.segmentrouting.storekey; |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 18 | |
| 19 | import java.util.Objects; |
| 20 | |
| 21 | import org.onosproject.net.DeviceId; |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 22 | import org.onosproject.segmentrouting.grouphandler.NeighborSet; |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 23 | |
| 24 | /** |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 25 | * Key of Neighborset next objective store. |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 26 | */ |
| 27 | public class NeighborSetNextObjectiveStoreKey { |
| 28 | private final DeviceId deviceId; |
| 29 | private final NeighborSet ns; |
| 30 | |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 31 | /** |
| 32 | * Constructs the key of neighbor set next objective store. |
| 33 | * |
| 34 | * @param deviceId device ID |
| 35 | * @param ns neighbor set |
| 36 | */ |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 37 | public NeighborSetNextObjectiveStoreKey(DeviceId deviceId, |
| 38 | NeighborSet ns) { |
| 39 | this.deviceId = deviceId; |
| 40 | this.ns = ns; |
| 41 | } |
| 42 | |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 43 | /** |
| 44 | * Returns the device ID in the key. |
| 45 | * |
| 46 | * @return device ID |
| 47 | */ |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 48 | public DeviceId deviceId() { |
| 49 | return this.deviceId; |
| 50 | } |
| 51 | |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 52 | /** |
| 53 | * Returns the neighbor set in the key. |
| 54 | * |
| 55 | * @return neighbor set |
| 56 | */ |
Srikanth Vavilapalli | 7cd1671 | 2015-05-04 09:48:09 -0700 | [diff] [blame] | 57 | public NeighborSet neighborSet() { |
| 58 | return this.ns; |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public boolean equals(Object o) { |
| 63 | if (this == o) { |
| 64 | return true; |
| 65 | } |
| 66 | if (!(o instanceof NeighborSetNextObjectiveStoreKey)) { |
| 67 | return false; |
| 68 | } |
| 69 | NeighborSetNextObjectiveStoreKey that = |
| 70 | (NeighborSetNextObjectiveStoreKey) o; |
| 71 | return (Objects.equals(this.deviceId, that.deviceId) && |
| 72 | Objects.equals(this.ns, that.ns)); |
| 73 | } |
| 74 | |
| 75 | // The list of neighbor ids and label are used for comparison. |
| 76 | @Override |
| 77 | public int hashCode() { |
| 78 | int result = 17; |
| 79 | result = 31 * result + Objects.hashCode(this.deviceId) |
| 80 | + Objects.hashCode(this.ns); |
| 81 | |
| 82 | return result; |
| 83 | } |
| 84 | |
| 85 | @Override |
| 86 | public String toString() { |
| 87 | return "Device: " + deviceId + " Neighborset: " + ns; |
| 88 | } |
| 89 | } |