David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 180c109 | 2017-08-03 22:46:14 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 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 | package org.opencord.sadis; |
| 17 | |
Amit Ghosh | 38b232a | 2017-07-23 15:11:56 +0100 | [diff] [blame] | 18 | import org.onlab.packet.Ip4Address; |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 19 | import org.onlab.packet.MacAddress; |
amit.ghosh | 3b225bb | 2022-02-17 18:41:00 +0100 | [diff] [blame^] | 20 | import org.onlab.packet.VlanId; |
| 21 | |
Matteo Scandolo | e4f4b63 | 2020-01-07 23:54:35 +0000 | [diff] [blame] | 22 | import com.fasterxml.jackson.annotation.JsonProperty; |
Daniele Moro | 82d9a36 | 2019-11-06 23:51:20 +0000 | [diff] [blame] | 23 | |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 24 | import java.util.List; |
amit.ghosh | 3b225bb | 2022-02-17 18:41:00 +0100 | [diff] [blame^] | 25 | import java.util.Objects; |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 26 | |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 27 | /** |
| 28 | * Represents a unit of information about a subscriber or access device. |
| 29 | */ |
Gamze Abaka | 1e5ccf5 | 2018-07-02 11:59:03 +0000 | [diff] [blame] | 30 | public class SubscriberAndDeviceInformation extends BaseInformation { |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 31 | |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 32 | @JsonProperty(value = "nasPortId") |
| 33 | String nasPortId; |
| 34 | |
Amit Ghosh | d5d60cf | 2017-11-09 11:00:09 +0000 | [diff] [blame] | 35 | @JsonProperty(value = "uplinkPort") |
| 36 | int uplinkPort = -1; |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 37 | |
| 38 | @JsonProperty(value = "slot") |
Amit Ghosh | 38b232a | 2017-07-23 15:11:56 +0100 | [diff] [blame] | 39 | int slot = -1; |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 40 | |
| 41 | @JsonProperty(value = "hardwareIdentifier") |
| 42 | MacAddress hardwareIdentifier; |
| 43 | |
Amit Ghosh | 38b232a | 2017-07-23 15:11:56 +0100 | [diff] [blame] | 44 | @JsonProperty(value = "ipAddress") |
| 45 | Ip4Address ipAddress; |
| 46 | |
| 47 | @JsonProperty(value = "nasId") |
| 48 | String nasId; |
| 49 | |
David K. Bainbridge | 8bf98e0 | 2017-08-07 10:41:56 -0700 | [diff] [blame] | 50 | @JsonProperty(value = "circuitId") |
| 51 | String circuitId; |
| 52 | |
| 53 | @JsonProperty(value = "remoteId") |
| 54 | String remoteId; |
| 55 | |
amit.ghosh | 3b225bb | 2022-02-17 18:41:00 +0100 | [diff] [blame^] | 56 | @JsonProperty(value = "nniDhcpTrapVid") |
| 57 | VlanId nniDhcpTrapVid = VlanId.vlanId(VlanId.NO_VID); |
| 58 | |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 59 | @JsonProperty(value = "uniTagList") |
| 60 | List<UniTagInformation> uniTagList; |
Gamze Abaka | 1e5ccf5 | 2018-07-02 11:59:03 +0000 | [diff] [blame] | 61 | |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 62 | public SubscriberAndDeviceInformation() { |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | public final String nasPortId() { |
| 66 | return this.nasPortId; |
| 67 | } |
| 68 | |
| 69 | public final void setNasPortId(final String nasPortId) { |
| 70 | this.nasPortId = nasPortId; |
| 71 | } |
| 72 | |
Amit Ghosh | d5d60cf | 2017-11-09 11:00:09 +0000 | [diff] [blame] | 73 | public final int uplinkPort() { |
| 74 | return this.uplinkPort; |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 75 | } |
| 76 | |
Amit Ghosh | d5d60cf | 2017-11-09 11:00:09 +0000 | [diff] [blame] | 77 | public final void setUplinkPort(final int uplinkPort) { |
| 78 | this.uplinkPort = uplinkPort; |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | public final int slot() { |
| 82 | return this.slot; |
| 83 | } |
| 84 | |
| 85 | public final void setSlot(final int slot) { |
| 86 | this.slot = slot; |
| 87 | } |
| 88 | |
| 89 | public final MacAddress hardwareIdentifier() { |
| 90 | return this.hardwareIdentifier; |
| 91 | } |
| 92 | |
| 93 | public final void setHardwareIdentifier(final MacAddress hardwareIdentifier) { |
| 94 | this.hardwareIdentifier = hardwareIdentifier; |
| 95 | } |
| 96 | |
Amit Ghosh | 38b232a | 2017-07-23 15:11:56 +0100 | [diff] [blame] | 97 | public final Ip4Address ipAddress() { |
| 98 | return this.ipAddress; |
| 99 | } |
| 100 | |
| 101 | public final void setIPAddress(final Ip4Address ipAddress) { |
| 102 | this.ipAddress = ipAddress; |
| 103 | } |
| 104 | |
| 105 | public final String nasId() { |
| 106 | return this.nasId; |
| 107 | } |
| 108 | |
| 109 | public final void setNasId(final String nasId) { |
| 110 | this.nasId = nasId; |
| 111 | } |
David K. Bainbridge | 8bf98e0 | 2017-08-07 10:41:56 -0700 | [diff] [blame] | 112 | |
| 113 | public final String circuitId() { |
| 114 | return this.circuitId; |
| 115 | } |
| 116 | |
| 117 | public final void setCircuitId(final String circuitId) { |
| 118 | this.circuitId = circuitId; |
| 119 | } |
| 120 | |
| 121 | public final String remoteId() { |
| 122 | return this.remoteId; |
| 123 | } |
| 124 | |
| 125 | public final void setRemoteId(final String remoteId) { |
| 126 | this.remoteId = remoteId; |
| 127 | } |
| 128 | |
amit.ghosh | 3b225bb | 2022-02-17 18:41:00 +0100 | [diff] [blame^] | 129 | public final VlanId nniDhcpTrapVid() { |
| 130 | return this.nniDhcpTrapVid; |
| 131 | } |
| 132 | |
| 133 | public final void setNniDhcpTrapVid(final VlanId vid) { |
| 134 | this.nniDhcpTrapVid = vid; |
| 135 | } |
| 136 | |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 137 | public final List<UniTagInformation> uniTagList() { |
| 138 | return this.uniTagList; |
Gamze Abaka | 1e5ccf5 | 2018-07-02 11:59:03 +0000 | [diff] [blame] | 139 | } |
| 140 | |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 141 | public final void setUniTagList(final List<UniTagInformation> uniTagList) { |
| 142 | this.uniTagList = uniTagList; |
Gamze Abaka | 1e5ccf5 | 2018-07-02 11:59:03 +0000 | [diff] [blame] | 143 | } |
| 144 | |
Gamze Abaka | 1e5ccf5 | 2018-07-02 11:59:03 +0000 | [diff] [blame] | 145 | |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 146 | /* |
| 147 | * (non-Javadoc) |
| 148 | * |
| 149 | * @see java.lang.Object#hashCode() |
| 150 | */ |
| 151 | @Override |
| 152 | public int hashCode() { |
| 153 | final int prime = 31; |
| 154 | int result = 1; |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 155 | result = prime * result + (this.hardwareIdentifier == null ? 0 : this.hardwareIdentifier.hashCode()); |
| 156 | result = prime * result + (this.id == null ? 0 : this.id.hashCode()); |
| 157 | result = prime * result + (this.nasPortId == null ? 0 : this.nasPortId.hashCode()); |
Amit Ghosh | d5d60cf | 2017-11-09 11:00:09 +0000 | [diff] [blame] | 158 | result = prime * result + this.uplinkPort; |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 159 | result = prime * result + this.slot; |
Amit Ghosh | 38b232a | 2017-07-23 15:11:56 +0100 | [diff] [blame] | 160 | result = prime * result + (this.ipAddress == null ? 0 : this.ipAddress.hashCode()); |
| 161 | result = prime * result + (this.nasId == null ? 0 : this.nasId.hashCode()); |
David K. Bainbridge | 8bf98e0 | 2017-08-07 10:41:56 -0700 | [diff] [blame] | 162 | result = prime + result + (this.circuitId == null ? 0 : this.circuitId.hashCode()); |
| 163 | result = prime + result + (this.remoteId == null ? 0 : this.remoteId.hashCode()); |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 164 | result = prime + result + (this.uniTagList == null ? 0 : this.uniTagList.hashCode()); |
amit.ghosh | 3b225bb | 2022-02-17 18:41:00 +0100 | [diff] [blame^] | 165 | result = prime + result + (this.nniDhcpTrapVid != null ? this.nniDhcpTrapVid.hashCode() : 0); |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 166 | return result; |
| 167 | } |
| 168 | |
| 169 | /* |
| 170 | * (non-Javadoc) |
| 171 | * |
| 172 | * @see java.lang.Object#equals(java.lang.Object) |
| 173 | */ |
| 174 | @Override |
| 175 | public boolean equals(final Object obj) { |
| 176 | if (this == obj) { |
| 177 | return true; |
| 178 | } |
| 179 | if (obj == null) { |
| 180 | return false; |
| 181 | } |
| 182 | if (this.getClass() != obj.getClass()) { |
| 183 | return false; |
| 184 | } |
| 185 | final SubscriberAndDeviceInformation other = (SubscriberAndDeviceInformation) obj; |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 186 | |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 187 | if (this.hardwareIdentifier == null) { |
| 188 | if (other.hardwareIdentifier != null) { |
| 189 | return false; |
| 190 | } |
| 191 | } else if (!this.hardwareIdentifier.equals(other.hardwareIdentifier)) { |
| 192 | return false; |
| 193 | } |
| 194 | if (this.id == null) { |
| 195 | if (other.id != null) { |
| 196 | return false; |
| 197 | } |
| 198 | } else if (!this.id.equals(other.id)) { |
| 199 | return false; |
| 200 | } |
| 201 | if (this.nasPortId == null) { |
| 202 | if (other.nasPortId != null) { |
| 203 | return false; |
| 204 | } |
| 205 | } else if (!this.nasPortId.equals(other.nasPortId)) { |
| 206 | return false; |
| 207 | } |
Amit Ghosh | 38b232a | 2017-07-23 15:11:56 +0100 | [diff] [blame] | 208 | if (this.nasId == null) { |
| 209 | if (other.nasId != null) { |
| 210 | return false; |
| 211 | } |
| 212 | } else if (!this.nasId.equals(other.nasId)) { |
| 213 | return false; |
| 214 | } |
| 215 | if (this.ipAddress == null) { |
| 216 | if (other.ipAddress != null) { |
| 217 | return false; |
| 218 | } |
| 219 | } else if (!this.ipAddress.equals(other.ipAddress())) { |
| 220 | return false; |
| 221 | } |
Amit Ghosh | d5d60cf | 2017-11-09 11:00:09 +0000 | [diff] [blame] | 222 | if (this.uplinkPort != other.uplinkPort) { |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 223 | return false; |
| 224 | } |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 225 | |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 226 | if (this.slot != other.slot) { |
| 227 | return false; |
| 228 | } |
David K. Bainbridge | 8bf98e0 | 2017-08-07 10:41:56 -0700 | [diff] [blame] | 229 | if (this.circuitId == null) { |
| 230 | if (other.circuitId != null) { |
| 231 | return false; |
| 232 | } |
| 233 | } else if (!this.circuitId.equals(other.circuitId)) { |
| 234 | return false; |
| 235 | } |
| 236 | if (this.remoteId == null) { |
| 237 | if (other.remoteId != null) { |
| 238 | return false; |
| 239 | } |
| 240 | } else if (!this.remoteId.equals(other.remoteId)) { |
| 241 | return false; |
| 242 | } |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 243 | if (this.uniTagList == null) { |
| 244 | if (other.uniTagList != null) { |
Gamze Abaka | 1e5ccf5 | 2018-07-02 11:59:03 +0000 | [diff] [blame] | 245 | return false; |
| 246 | } |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 247 | } else if (!this.uniTagList.equals(other.uniTagList)) { |
Gamze Abaka | 1e5ccf5 | 2018-07-02 11:59:03 +0000 | [diff] [blame] | 248 | return false; |
| 249 | } |
amit.ghosh | 3b225bb | 2022-02-17 18:41:00 +0100 | [diff] [blame^] | 250 | if (!Objects.equals(this.nniDhcpTrapVid, other.nniDhcpTrapVid)) { |
| 251 | return false; |
| 252 | } |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 253 | return true; |
| 254 | } |
| 255 | |
| 256 | /* |
| 257 | * (non-Javadoc) |
| 258 | * |
| 259 | * @see java.lang.Object#toString() |
| 260 | */ |
| 261 | @Override |
| 262 | public String toString() { |
| 263 | final StringBuilder buf = new StringBuilder(); |
| 264 | buf.append('['); |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 265 | buf.append("id:").append(this.id); |
| 266 | buf.append(",nasPortId:").append(this.nasPortId); |
| 267 | buf.append(",uplinkPort:").append(this.uplinkPort); |
| 268 | buf.append(",slot:").append(this.slot); |
| 269 | buf.append(",hardwareIdentifier:").append(this.hardwareIdentifier); |
| 270 | buf.append(",ipaddress:").append(this.ipAddress); |
| 271 | buf.append(",nasId:").append(this.nasId); |
| 272 | buf.append(",circuitId:").append(this.circuitId); |
| 273 | buf.append(",remoteId:").append(this.remoteId); |
amit.ghosh | 3b225bb | 2022-02-17 18:41:00 +0100 | [diff] [blame^] | 274 | buf.append(",nniDhcpTrapVid:").append(this.nniDhcpTrapVid); |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 275 | buf.append(",uniTagList:").append(this.uniTagList); |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 276 | buf.append(']'); |
| 277 | |
| 278 | return buf.toString(); |
| 279 | } |
| 280 | |
| 281 | } |