blob: 48c93f7dd2347cc1a40e42dcf0465eb6096df7c8 [file] [log] [blame]
Brian O'Connor7cbbbb72016-04-09 02:13:23 -07001/*
2 * Copyright 2015-present 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 */
Saurav Das0e99e2b2015-10-28 12:39:42 -070016package org.onosproject.segmentrouting;
17
18import java.util.Objects;
19
20import org.onlab.packet.Ip4Prefix;
21import org.onosproject.net.DeviceId;
22
23/**
Charles Chane849c192016-01-11 18:28:54 -080024 * Key of assigned VLAN ID store.
Saurav Das0e99e2b2015-10-28 12:39:42 -070025 */
26public class SubnetAssignedVidStoreKey {
27 private final DeviceId deviceId;
28 private final Ip4Prefix subnet;
29
Charles Chane849c192016-01-11 18:28:54 -080030 /**
31 * Constructs the key of per subnet VLAN ID store.
32 *
33 * @param deviceId device ID of the VLAN cross-connection
34 * @param subnet subnet information
35 */
Saurav Das0e99e2b2015-10-28 12:39:42 -070036 public SubnetAssignedVidStoreKey(DeviceId deviceId, Ip4Prefix subnet) {
37 this.deviceId = deviceId;
38 this.subnet = subnet;
39 }
40
41 /**
42 * Returns the device identification used to create this key.
43 *
44 * @return the device identifier
45 */
46 public DeviceId deviceId() {
47 return deviceId;
48 }
49
50 /**
51 * Returns the subnet information used to create this key.
52 *
53 * @return the subnet
54 */
55 public Ip4Prefix subnet() {
56 return subnet;
57 }
58
59 @Override
60 public boolean equals(Object o) {
61 if (this == o) {
62 return true;
63 }
64 if (!(o instanceof SubnetAssignedVidStoreKey)) {
65 return false;
66 }
67 SubnetAssignedVidStoreKey that =
68 (SubnetAssignedVidStoreKey) o;
69 return (Objects.equals(this.deviceId, that.deviceId) &&
70 Objects.equals(this.subnet, that.subnet));
71 }
72
73 @Override
74 public int hashCode() {
75 int result = 17;
76 result = 31 * result + Objects.hashCode(deviceId)
77 + Objects.hashCode(subnet);
78 return result;
79 }
80
81 @Override
82 public String toString() {
83 return "Device: " + deviceId + " Subnet: " + subnet;
84 }
85
86}