blob: 9b6e62112d5a34b30d8ac98644ac92a8b50c35c6 [file] [log] [blame]
Saurav Das261c3002017-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
24/**
25 * Key of Destination set next objective store.
26 */
27public class DestinationSetNextObjectiveStoreKey {
28 private final DeviceId deviceId;
29 private final DestinationSet ds;
30
31 /**
32 * Constructs the key of destination set next objective store.
33 *
34 * @param deviceId device ID
35 * @param ds destination set
36 */
37 public DestinationSetNextObjectiveStoreKey(DeviceId deviceId,
38 DestinationSet ds) {
39 this.deviceId = deviceId;
40 this.ds = ds;
41 }
42
43 /**
44 * Returns the device ID in the key.
45 *
46 * @return device ID
47 */
48 public DeviceId deviceId() {
49 return this.deviceId;
50 }
51
52 /**
53 * Returns the destination set in the key.
54 *
55 * @return destination set
56 */
57 public DestinationSet destinationSet() {
58 return this.ds;
59 }
60
61 @Override
62 public boolean equals(Object o) {
63 if (this == o) {
64 return true;
65 }
66 if (!(o instanceof DestinationSetNextObjectiveStoreKey)) {
67 return false;
68 }
69 DestinationSetNextObjectiveStoreKey that =
70 (DestinationSetNextObjectiveStoreKey) o;
71 return (Objects.equals(this.deviceId, that.deviceId) &&
72 Objects.equals(this.ds, that.ds));
73 }
74
75 // The list of destination 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.ds);
81
82 return result;
83 }
84
85 @Override
86 public String toString() {
87 return "Device: " + deviceId + " " + ds;
88 }
89}