Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Foundation |
| 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/licedses/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 | |
| 17 | package org.onosproject.segmentrouting.storekey; |
| 18 | |
| 19 | import java.util.Objects; |
| 20 | |
| 21 | import org.onosproject.net.DeviceId; |
| 22 | import org.onosproject.segmentrouting.grouphandler.DestinationSet; |
| 23 | |
Ruchi Sahota | 71bcb4e | 2019-01-28 01:08:18 +0000 | [diff] [blame] | 24 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 25 | |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 26 | /** |
| 27 | * Key of Destination set next objective store. |
| 28 | */ |
| 29 | public class DestinationSetNextObjectiveStoreKey { |
| 30 | private final DeviceId deviceId; |
| 31 | private final DestinationSet ds; |
| 32 | |
| 33 | /** |
| 34 | * Constructs the key of destination set next objective store. |
| 35 | * |
| 36 | * @param deviceId device ID |
| 37 | * @param ds destination set |
| 38 | */ |
| 39 | public DestinationSetNextObjectiveStoreKey(DeviceId deviceId, |
| 40 | DestinationSet ds) { |
| 41 | this.deviceId = deviceId; |
| 42 | this.ds = ds; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Returns the device ID in the key. |
| 47 | * |
| 48 | * @return device ID |
| 49 | */ |
| 50 | public DeviceId deviceId() { |
| 51 | return this.deviceId; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Returns the destination set in the key. |
| 56 | * |
| 57 | * @return destination set |
| 58 | */ |
| 59 | public DestinationSet destinationSet() { |
| 60 | return this.ds; |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public boolean equals(Object o) { |
| 65 | if (this == o) { |
| 66 | return true; |
| 67 | } |
| 68 | if (!(o instanceof DestinationSetNextObjectiveStoreKey)) { |
| 69 | return false; |
| 70 | } |
| 71 | DestinationSetNextObjectiveStoreKey that = |
| 72 | (DestinationSetNextObjectiveStoreKey) o; |
| 73 | return (Objects.equals(this.deviceId, that.deviceId) && |
| 74 | Objects.equals(this.ds, that.ds)); |
| 75 | } |
| 76 | |
| 77 | // The list of destination ids and label are used for comparison. |
| 78 | @Override |
| 79 | public int hashCode() { |
| 80 | int result = 17; |
| 81 | result = 31 * result + Objects.hashCode(this.deviceId) |
| 82 | + Objects.hashCode(this.ds); |
| 83 | |
| 84 | return result; |
| 85 | } |
| 86 | |
| 87 | @Override |
| 88 | public String toString() { |
Ruchi Sahota | 71bcb4e | 2019-01-28 01:08:18 +0000 | [diff] [blame] | 89 | return toStringHelper(getClass()) |
| 90 | .add("deviceId", deviceId) |
| 91 | .add("ds", ds) |
| 92 | .toString(); |
Saurav Das | 261c300 | 2017-06-13 15:35:54 -0700 | [diff] [blame] | 93 | } |
| 94 | } |