blob: d6b16c7a738b4c2e98d3b8174cdf6ea62a7fb72e [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/**
25 * Class definition of Key for Subnet to NextObjective store.
26 */
27public class SubnetNextObjectiveStoreKey {
28 private final DeviceId deviceId;
29 private final IpPrefix prefix;
30
31 public SubnetNextObjectiveStoreKey(DeviceId deviceId,
32 IpPrefix prefix) {
33 this.deviceId = deviceId;
34 this.prefix = prefix;
35 }
36
37 /**
38 * Gets device id in this SubnetNextObjectiveStoreKey.
39 *
40 * @return device id
41 */
42 public DeviceId deviceId() {
43 return this.deviceId;
44 }
45
46 /**
47 * Gets subnet information in this SubnetNextObjectiveStoreKey.
48 *
49 * @return subnet information
50 */
51 public IpPrefix prefix() {
52 return this.prefix;
53 }
54
55 @Override
56 public boolean equals(Object o) {
57 if (this == o) {
58 return true;
59 }
60 if (!(o instanceof SubnetNextObjectiveStoreKey)) {
61 return false;
62 }
63 SubnetNextObjectiveStoreKey that =
64 (SubnetNextObjectiveStoreKey) o;
65 return (Objects.equals(this.deviceId, that.deviceId) &&
66 Objects.equals(this.prefix, that.prefix));
67 }
68
69 @Override
70 public int hashCode() {
71 return Objects.hash(deviceId, prefix);
72 }
73
74 @Override
75 public String toString() {
76 return "Device: " + deviceId + " Subnet: " + prefix;
77 }
78}