blob: 0baa769b52772224b5a248923ff15a33aa40000b [file] [log] [blame]
Saurav Das7bcbe702017-06-13 15:35:54 -07001/*
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
17package org.onosproject.segmentrouting.storekey;
18
19import java.util.Objects;
20
21import org.onosproject.net.DeviceId;
22import org.onosproject.segmentrouting.grouphandler.DestinationSet;
23
Ruchi Sahotaef0761c2019-01-28 01:08:18 +000024import static com.google.common.base.MoreObjects.toStringHelper;
25
Saurav Das7bcbe702017-06-13 15:35:54 -070026/**
27 * Key of Destination set next objective store.
28 */
29public 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 Sahotaef0761c2019-01-28 01:08:18 +000089 return toStringHelper(getClass())
90 .add("deviceId", deviceId)
91 .add("ds", ds)
92 .toString();
Saurav Das7bcbe702017-06-13 15:35:54 -070093 }
94}