blob: f1fa614f95f925df3f5f9a211677c47d61868eff [file] [log] [blame]
Srikanth Vavilapalli23181912015-05-04 09:48:09 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
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
17package org.onosproject.segmentrouting.grouphandler;
18
19import java.util.Objects;
20
21import org.onosproject.net.DeviceId;
22
23/**
Charles Chane849c192016-01-11 18:28:54 -080024 * Key of Neighborset next objective store.
Srikanth Vavilapalli23181912015-05-04 09:48:09 -070025 */
26public class NeighborSetNextObjectiveStoreKey {
27 private final DeviceId deviceId;
28 private final NeighborSet ns;
29
Charles Chane849c192016-01-11 18:28:54 -080030 /**
31 * Constructs the key of neighbor set next objective store.
32 *
33 * @param deviceId device ID
34 * @param ns neighbor set
35 */
Srikanth Vavilapalli23181912015-05-04 09:48:09 -070036 public NeighborSetNextObjectiveStoreKey(DeviceId deviceId,
37 NeighborSet ns) {
38 this.deviceId = deviceId;
39 this.ns = ns;
40 }
41
Charles Chane849c192016-01-11 18:28:54 -080042 /**
43 * Returns the device ID in the key.
44 *
45 * @return device ID
46 */
Srikanth Vavilapalli23181912015-05-04 09:48:09 -070047 public DeviceId deviceId() {
48 return this.deviceId;
49 }
50
Charles Chane849c192016-01-11 18:28:54 -080051 /**
52 * Returns the neighbor set in the key.
53 *
54 * @return neighbor set
55 */
Srikanth Vavilapalli23181912015-05-04 09:48:09 -070056 public NeighborSet neighborSet() {
57 return this.ns;
58 }
59
60 @Override
61 public boolean equals(Object o) {
62 if (this == o) {
63 return true;
64 }
65 if (!(o instanceof NeighborSetNextObjectiveStoreKey)) {
66 return false;
67 }
68 NeighborSetNextObjectiveStoreKey that =
69 (NeighborSetNextObjectiveStoreKey) o;
70 return (Objects.equals(this.deviceId, that.deviceId) &&
71 Objects.equals(this.ns, that.ns));
72 }
73
74 // The list of neighbor ids and label are used for comparison.
75 @Override
76 public int hashCode() {
77 int result = 17;
78 result = 31 * result + Objects.hashCode(this.deviceId)
79 + Objects.hashCode(this.ns);
80
81 return result;
82 }
83
84 @Override
85 public String toString() {
86 return "Device: " + deviceId + " Neighborset: " + ns;
87 }
88}