blob: b9ce6a9f4011f555dc285110854c2266bd093c61 [file] [log] [blame]
Srikanth Vavilapalli23181912015-05-04 09:48:09 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Srikanth Vavilapalli23181912015-05-04 09:48:09 -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 */
16
Charles Chand2990362016-04-18 13:44:03 -070017package org.onosproject.segmentrouting.storekey;
Srikanth Vavilapalli23181912015-05-04 09:48:09 -070018
19import java.util.Objects;
20
21import org.onosproject.net.DeviceId;
Charles Chand2990362016-04-18 13:44:03 -070022import org.onosproject.segmentrouting.grouphandler.NeighborSet;
Srikanth Vavilapalli23181912015-05-04 09:48:09 -070023
24/**
Charles Chane849c192016-01-11 18:28:54 -080025 * Key of Neighborset next objective store.
Srikanth Vavilapalli23181912015-05-04 09:48:09 -070026 */
27public class NeighborSetNextObjectiveStoreKey {
28 private final DeviceId deviceId;
29 private final NeighborSet ns;
30
Charles Chane849c192016-01-11 18:28:54 -080031 /**
32 * Constructs the key of neighbor set next objective store.
33 *
34 * @param deviceId device ID
35 * @param ns neighbor set
36 */
Srikanth Vavilapalli23181912015-05-04 09:48:09 -070037 public NeighborSetNextObjectiveStoreKey(DeviceId deviceId,
38 NeighborSet ns) {
39 this.deviceId = deviceId;
40 this.ns = ns;
41 }
42
Charles Chane849c192016-01-11 18:28:54 -080043 /**
44 * Returns the device ID in the key.
45 *
46 * @return device ID
47 */
Srikanth Vavilapalli23181912015-05-04 09:48:09 -070048 public DeviceId deviceId() {
49 return this.deviceId;
50 }
51
Charles Chane849c192016-01-11 18:28:54 -080052 /**
53 * Returns the neighbor set in the key.
54 *
55 * @return neighbor set
56 */
Srikanth Vavilapalli23181912015-05-04 09:48:09 -070057 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() {
Saurav Dasc88d4662017-05-15 15:34:25 -070087 return "Device: " + deviceId + " " + ns;
Srikanth Vavilapalli23181912015-05-04 09:48:09 -070088 }
89}