blob: 8e5c3cefd5e3faa7c2e7fee37a3ac685bea59953 [file] [log] [blame]
Charles Chanc42e84e2015-10-20 16:24:19 -07001/*
2 * Copyright 2014-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 org.onlab.packet.IpPrefix;
20import org.onosproject.net.DeviceId;
21
22import java.util.Objects;
23
24/**
Charles Chane849c192016-01-11 18:28:54 -080025 * Key of Subnet to NextObjective store.
Charles Chanc42e84e2015-10-20 16:24:19 -070026 */
27public class SubnetNextObjectiveStoreKey {
28 private final DeviceId deviceId;
29 private final IpPrefix prefix;
30
Charles Chane849c192016-01-11 18:28:54 -080031 /**
32 * Constructs the key of subnet next objective store.
33 *
34 * @param deviceId device ID
35 * @param prefix subnet information
36 */
Charles Chanc42e84e2015-10-20 16:24:19 -070037 public SubnetNextObjectiveStoreKey(DeviceId deviceId,
38 IpPrefix prefix) {
39 this.deviceId = deviceId;
40 this.prefix = prefix;
41 }
42
43 /**
44 * Gets device id in this SubnetNextObjectiveStoreKey.
45 *
46 * @return device id
47 */
48 public DeviceId deviceId() {
49 return this.deviceId;
50 }
51
52 /**
53 * Gets subnet information in this SubnetNextObjectiveStoreKey.
54 *
55 * @return subnet information
56 */
57 public IpPrefix prefix() {
58 return this.prefix;
59 }
60
61 @Override
62 public boolean equals(Object o) {
63 if (this == o) {
64 return true;
65 }
66 if (!(o instanceof SubnetNextObjectiveStoreKey)) {
67 return false;
68 }
69 SubnetNextObjectiveStoreKey that =
70 (SubnetNextObjectiveStoreKey) o;
71 return (Objects.equals(this.deviceId, that.deviceId) &&
72 Objects.equals(this.prefix, that.prefix));
73 }
74
75 @Override
76 public int hashCode() {
77 return Objects.hash(deviceId, prefix);
78 }
79
80 @Override
81 public String toString() {
82 return "Device: " + deviceId + " Subnet: " + prefix;
83 }
84}