blob: 9ace531360bcf50a570f0e96f35d8f9464b0e17e [file] [log] [blame]
Srikanth Vavilapalli23181912015-05-04 09:48:09 -07001/*
2 * Copyright 2015 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 */
16
17package org.onosproject.segmentrouting.grouphandler;
18
19import java.util.Objects;
20
21import org.onosproject.net.DeviceId;
22
23/**
24 * Class definition of Key for Neighborset to NextObjective store.
25 */
26public class NeighborSetNextObjectiveStoreKey {
27 private final DeviceId deviceId;
28 private final NeighborSet ns;
29
30 public NeighborSetNextObjectiveStoreKey(DeviceId deviceId,
31 NeighborSet ns) {
32 this.deviceId = deviceId;
33 this.ns = ns;
34 }
35
36 public DeviceId deviceId() {
37 return this.deviceId;
38 }
39
40 public NeighborSet neighborSet() {
41 return this.ns;
42 }
43
44 @Override
45 public boolean equals(Object o) {
46 if (this == o) {
47 return true;
48 }
49 if (!(o instanceof NeighborSetNextObjectiveStoreKey)) {
50 return false;
51 }
52 NeighborSetNextObjectiveStoreKey that =
53 (NeighborSetNextObjectiveStoreKey) o;
54 return (Objects.equals(this.deviceId, that.deviceId) &&
55 Objects.equals(this.ns, that.ns));
56 }
57
58 // The list of neighbor ids and label are used for comparison.
59 @Override
60 public int hashCode() {
61 int result = 17;
62 result = 31 * result + Objects.hashCode(this.deviceId)
63 + Objects.hashCode(this.ns);
64
65 return result;
66 }
67
68 @Override
69 public String toString() {
70 return "Device: " + deviceId + " Neighborset: " + ns;
71 }
72}