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; |
Daniele Moro | efe448c | 2019-11-06 23:33:43 +0000 | [diff] [blame^] | 20 | import org.onlab.packet.VlanId; |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 21 | |
Daniele Moro | efe448c | 2019-11-06 23:33:43 +0000 | [diff] [blame^] | 22 | import com.fasterxml.jackson.annotation.JsonProperty; |
Gamze Abaka | 94f12a0 | 2019-08-21 07:21:41 +0000 | [diff] [blame] | 23 | |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 24 | /** |
| 25 | * Represents a unit of information about a subscriber or access device. |
| 26 | */ |
Gamze Abaka | 1e5ccf5 | 2018-07-02 11:59:03 +0000 | [diff] [blame] | 27 | public class SubscriberAndDeviceInformation extends BaseInformation { |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 28 | |
Daniele Moro | efe448c | 2019-11-06 23:33:43 +0000 | [diff] [blame^] | 29 | |
| 30 | @JsonProperty(value = "sTag") |
| 31 | VlanId sTag; |
| 32 | |
| 33 | @JsonProperty(value = "cTag") |
| 34 | VlanId cTag; |
| 35 | |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 36 | @JsonProperty(value = "nasPortId") |
| 37 | String nasPortId; |
| 38 | |
Amit Ghosh | d5d60cf | 2017-11-09 11:00:09 +0000 | [diff] [blame] | 39 | @JsonProperty(value = "uplinkPort") |
| 40 | int uplinkPort = -1; |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 41 | |
| 42 | @JsonProperty(value = "slot") |
Amit Ghosh | 38b232a | 2017-07-23 15:11:56 +0100 | [diff] [blame] | 43 | int slot = -1; |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 44 | |
| 45 | @JsonProperty(value = "hardwareIdentifier") |
| 46 | MacAddress hardwareIdentifier; |
| 47 | |
Amit Ghosh | 38b232a | 2017-07-23 15:11:56 +0100 | [diff] [blame] | 48 | @JsonProperty(value = "ipAddress") |
| 49 | Ip4Address ipAddress; |
| 50 | |
| 51 | @JsonProperty(value = "nasId") |
| 52 | String nasId; |
| 53 | |
David K. Bainbridge | 8bf98e0 | 2017-08-07 10:41:56 -0700 | [diff] [blame] | 54 | @JsonProperty(value = "circuitId") |
| 55 | String circuitId; |
| 56 | |
| 57 | @JsonProperty(value = "remoteId") |
| 58 | String remoteId; |
| 59 | |
Daniele Moro | efe448c | 2019-11-06 23:33:43 +0000 | [diff] [blame^] | 60 | @JsonProperty(value = "technologyProfileId") |
| 61 | int technologyProfileId = -1; |
Gamze Abaka | 1e5ccf5 | 2018-07-02 11:59:03 +0000 | [diff] [blame] | 62 | |
Daniele Moro | efe448c | 2019-11-06 23:33:43 +0000 | [diff] [blame^] | 63 | @JsonProperty(value = "upstreamBandwidthProfile") |
| 64 | String upstreamBandwidthProfile; |
| 65 | |
| 66 | @JsonProperty(value = "downstreamBandwidthProfile") |
| 67 | String downstreamBandwidthProfile; |
| 68 | |
| 69 | protected SubscriberAndDeviceInformation() { |
| 70 | } |
| 71 | |
| 72 | public final VlanId sTag() { |
| 73 | return this.sTag; |
| 74 | } |
| 75 | |
| 76 | public final void setSTag(final VlanId stag) { |
| 77 | this.sTag = stag; |
| 78 | } |
| 79 | |
| 80 | public final VlanId cTag() { |
| 81 | return this.cTag; |
| 82 | } |
| 83 | |
| 84 | public final void setCTag(final VlanId ctag) { |
| 85 | this.cTag = ctag; |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | public final String nasPortId() { |
| 89 | return this.nasPortId; |
| 90 | } |
| 91 | |
| 92 | public final void setNasPortId(final String nasPortId) { |
| 93 | this.nasPortId = nasPortId; |
| 94 | } |
| 95 | |
Amit Ghosh | d5d60cf | 2017-11-09 11:00:09 +0000 | [diff] [blame] | 96 | public final int uplinkPort() { |
| 97 | return this.uplinkPort; |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 98 | } |
| 99 | |
Amit Ghosh | d5d60cf | 2017-11-09 11:00:09 +0000 | [diff] [blame] | 100 | public final void setUplinkPort(final int uplinkPort) { |
| 101 | this.uplinkPort = uplinkPort; |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | public final int slot() { |
| 105 | return this.slot; |
| 106 | } |
| 107 | |
| 108 | public final void setSlot(final int slot) { |
| 109 | this.slot = slot; |
| 110 | } |
| 111 | |
| 112 | public final MacAddress hardwareIdentifier() { |
| 113 | return this.hardwareIdentifier; |
| 114 | } |
| 115 | |
| 116 | public final void setHardwareIdentifier(final MacAddress hardwareIdentifier) { |
| 117 | this.hardwareIdentifier = hardwareIdentifier; |
| 118 | } |
| 119 | |
Amit Ghosh | 38b232a | 2017-07-23 15:11:56 +0100 | [diff] [blame] | 120 | public final Ip4Address ipAddress() { |
| 121 | return this.ipAddress; |
| 122 | } |
| 123 | |
| 124 | public final void setIPAddress(final Ip4Address ipAddress) { |
| 125 | this.ipAddress = ipAddress; |
| 126 | } |
| 127 | |
| 128 | public final String nasId() { |
| 129 | return this.nasId; |
| 130 | } |
| 131 | |
| 132 | public final void setNasId(final String nasId) { |
| 133 | this.nasId = nasId; |
| 134 | } |
David K. Bainbridge | 8bf98e0 | 2017-08-07 10:41:56 -0700 | [diff] [blame] | 135 | |
| 136 | public final String circuitId() { |
| 137 | return this.circuitId; |
| 138 | } |
| 139 | |
| 140 | public final void setCircuitId(final String circuitId) { |
| 141 | this.circuitId = circuitId; |
| 142 | } |
| 143 | |
| 144 | public final String remoteId() { |
| 145 | return this.remoteId; |
| 146 | } |
| 147 | |
| 148 | public final void setRemoteId(final String remoteId) { |
| 149 | this.remoteId = remoteId; |
| 150 | } |
| 151 | |
Daniele Moro | efe448c | 2019-11-06 23:33:43 +0000 | [diff] [blame^] | 152 | public final int technologyProfileId() { |
| 153 | return this.technologyProfileId; |
Gamze Abaka | 1e5ccf5 | 2018-07-02 11:59:03 +0000 | [diff] [blame] | 154 | } |
| 155 | |
Daniele Moro | efe448c | 2019-11-06 23:33:43 +0000 | [diff] [blame^] | 156 | public final void setTechnologyProfileId(final int technologyProfileId) { |
| 157 | this.technologyProfileId = technologyProfileId; |
Gamze Abaka | 1e5ccf5 | 2018-07-02 11:59:03 +0000 | [diff] [blame] | 158 | } |
| 159 | |
Daniele Moro | efe448c | 2019-11-06 23:33:43 +0000 | [diff] [blame^] | 160 | public final String upstreamBandwidthProfile() { |
| 161 | return this.upstreamBandwidthProfile; |
| 162 | } |
| 163 | |
| 164 | public final void setUpstreamBandwidthProfile(final String upstreamBandwidthProfile) { |
| 165 | this.upstreamBandwidthProfile = upstreamBandwidthProfile; |
| 166 | } |
| 167 | |
| 168 | public final String downstreamBandwidthProfile() { |
| 169 | return this.downstreamBandwidthProfile; |
| 170 | } |
| 171 | |
| 172 | public final void setDownstreamBandwidthProfile(final String downstreamBandwidthProfile) { |
| 173 | this.downstreamBandwidthProfile = downstreamBandwidthProfile; |
| 174 | } |
Gamze Abaka | 1e5ccf5 | 2018-07-02 11:59:03 +0000 | [diff] [blame] | 175 | |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 176 | /* |
| 177 | * (non-Javadoc) |
| 178 | * |
| 179 | * @see java.lang.Object#hashCode() |
| 180 | */ |
| 181 | @Override |
| 182 | public int hashCode() { |
| 183 | final int prime = 31; |
| 184 | int result = 1; |
Daniele Moro | efe448c | 2019-11-06 23:33:43 +0000 | [diff] [blame^] | 185 | result = prime * result + (this.cTag == null ? 0 : this.cTag.hashCode()); |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 186 | result = prime * result + (this.hardwareIdentifier == null ? 0 : this.hardwareIdentifier.hashCode()); |
| 187 | result = prime * result + (this.id == null ? 0 : this.id.hashCode()); |
| 188 | result = prime * result + (this.nasPortId == null ? 0 : this.nasPortId.hashCode()); |
Amit Ghosh | d5d60cf | 2017-11-09 11:00:09 +0000 | [diff] [blame] | 189 | result = prime * result + this.uplinkPort; |
Daniele Moro | efe448c | 2019-11-06 23:33:43 +0000 | [diff] [blame^] | 190 | result = prime * result + (this.sTag == null ? 0 : this.sTag.hashCode()); |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 191 | result = prime * result + this.slot; |
Amit Ghosh | 38b232a | 2017-07-23 15:11:56 +0100 | [diff] [blame] | 192 | result = prime * result + (this.ipAddress == null ? 0 : this.ipAddress.hashCode()); |
| 193 | result = prime * result + (this.nasId == null ? 0 : this.nasId.hashCode()); |
David K. Bainbridge | 8bf98e0 | 2017-08-07 10:41:56 -0700 | [diff] [blame] | 194 | result = prime + result + (this.circuitId == null ? 0 : this.circuitId.hashCode()); |
| 195 | result = prime + result + (this.remoteId == null ? 0 : this.remoteId.hashCode()); |
Daniele Moro | efe448c | 2019-11-06 23:33:43 +0000 | [diff] [blame^] | 196 | result = prime + result + this.technologyProfileId; |
| 197 | result = prime + result + |
| 198 | (this.upstreamBandwidthProfile == null ? 0 : this.upstreamBandwidthProfile.hashCode()); |
| 199 | result = prime + result + |
| 200 | (this.downstreamBandwidthProfile == null ? 0 : this.downstreamBandwidthProfile.hashCode()); |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 201 | return result; |
| 202 | } |
| 203 | |
| 204 | /* |
| 205 | * (non-Javadoc) |
| 206 | * |
| 207 | * @see java.lang.Object#equals(java.lang.Object) |
| 208 | */ |
| 209 | @Override |
| 210 | public boolean equals(final Object obj) { |
| 211 | if (this == obj) { |
| 212 | return true; |
| 213 | } |
| 214 | if (obj == null) { |
| 215 | return false; |
| 216 | } |
| 217 | if (this.getClass() != obj.getClass()) { |
| 218 | return false; |
| 219 | } |
| 220 | final SubscriberAndDeviceInformation other = (SubscriberAndDeviceInformation) obj; |
Daniele Moro | efe448c | 2019-11-06 23:33:43 +0000 | [diff] [blame^] | 221 | if (this.cTag == null) { |
| 222 | if (other.cTag != null) { |
| 223 | return false; |
| 224 | } |
| 225 | } else if (!this.cTag.equals(other.cTag)) { |
| 226 | return false; |
| 227 | } |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 228 | if (this.hardwareIdentifier == null) { |
| 229 | if (other.hardwareIdentifier != null) { |
| 230 | return false; |
| 231 | } |
| 232 | } else if (!this.hardwareIdentifier.equals(other.hardwareIdentifier)) { |
| 233 | return false; |
| 234 | } |
| 235 | if (this.id == null) { |
| 236 | if (other.id != null) { |
| 237 | return false; |
| 238 | } |
| 239 | } else if (!this.id.equals(other.id)) { |
| 240 | return false; |
| 241 | } |
| 242 | if (this.nasPortId == null) { |
| 243 | if (other.nasPortId != null) { |
| 244 | return false; |
| 245 | } |
| 246 | } else if (!this.nasPortId.equals(other.nasPortId)) { |
| 247 | return false; |
| 248 | } |
Amit Ghosh | 38b232a | 2017-07-23 15:11:56 +0100 | [diff] [blame] | 249 | if (this.nasId == null) { |
| 250 | if (other.nasId != null) { |
| 251 | return false; |
| 252 | } |
| 253 | } else if (!this.nasId.equals(other.nasId)) { |
| 254 | return false; |
| 255 | } |
| 256 | if (this.ipAddress == null) { |
| 257 | if (other.ipAddress != null) { |
| 258 | return false; |
| 259 | } |
| 260 | } else if (!this.ipAddress.equals(other.ipAddress())) { |
| 261 | return false; |
| 262 | } |
Amit Ghosh | d5d60cf | 2017-11-09 11:00:09 +0000 | [diff] [blame] | 263 | if (this.uplinkPort != other.uplinkPort) { |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 264 | return false; |
| 265 | } |
Daniele Moro | efe448c | 2019-11-06 23:33:43 +0000 | [diff] [blame^] | 266 | if (this.sTag == null) { |
| 267 | if (other.sTag != null) { |
| 268 | return false; |
| 269 | } |
| 270 | } else if (!this.sTag.equals(other.sTag)) { |
| 271 | return false; |
| 272 | } |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 273 | if (this.slot != other.slot) { |
| 274 | return false; |
| 275 | } |
David K. Bainbridge | 8bf98e0 | 2017-08-07 10:41:56 -0700 | [diff] [blame] | 276 | if (this.circuitId == null) { |
| 277 | if (other.circuitId != null) { |
| 278 | return false; |
| 279 | } |
| 280 | } else if (!this.circuitId.equals(other.circuitId)) { |
| 281 | return false; |
| 282 | } |
| 283 | if (this.remoteId == null) { |
| 284 | if (other.remoteId != null) { |
| 285 | return false; |
| 286 | } |
| 287 | } else if (!this.remoteId.equals(other.remoteId)) { |
| 288 | return false; |
| 289 | } |
Daniele Moro | efe448c | 2019-11-06 23:33:43 +0000 | [diff] [blame^] | 290 | if (this.technologyProfileId != other.technologyProfileId) { |
| 291 | return false; |
| 292 | } |
| 293 | if (this.upstreamBandwidthProfile == null) { |
| 294 | if (other.upstreamBandwidthProfile != null) { |
Gamze Abaka | 1e5ccf5 | 2018-07-02 11:59:03 +0000 | [diff] [blame] | 295 | return false; |
| 296 | } |
Daniele Moro | efe448c | 2019-11-06 23:33:43 +0000 | [diff] [blame^] | 297 | } else if (!this.upstreamBandwidthProfile.equals(other.upstreamBandwidthProfile)) { |
| 298 | return false; |
| 299 | } |
| 300 | if (this.downstreamBandwidthProfile == null) { |
| 301 | if (other.downstreamBandwidthProfile != null) { |
| 302 | return false; |
| 303 | } |
| 304 | } else if (!this.downstreamBandwidthProfile.equals(other.downstreamBandwidthProfile)) { |
Gamze Abaka | 1e5ccf5 | 2018-07-02 11:59:03 +0000 | [diff] [blame] | 305 | return false; |
| 306 | } |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 307 | return true; |
| 308 | } |
| 309 | |
| 310 | /* |
| 311 | * (non-Javadoc) |
| 312 | * |
| 313 | * @see java.lang.Object#toString() |
| 314 | */ |
| 315 | @Override |
| 316 | public String toString() { |
| 317 | final StringBuilder buf = new StringBuilder(); |
| 318 | buf.append('['); |
Daniele Moro | efe448c | 2019-11-06 23:33:43 +0000 | [diff] [blame^] | 319 | buf.append("id:"); |
| 320 | buf.append(this.id); |
| 321 | buf.append(",cTag:"); |
| 322 | buf.append(this.cTag); |
| 323 | buf.append(",sTag:"); |
| 324 | buf.append(this.sTag); |
| 325 | buf.append(",nasPortId:"); |
| 326 | buf.append(this.nasPortId); |
| 327 | buf.append(",uplinkPort:"); |
| 328 | buf.append(this.uplinkPort); |
| 329 | buf.append(",slot:"); |
| 330 | buf.append(this.slot); |
| 331 | buf.append(",hardwareIdentifier:"); |
| 332 | buf.append(this.hardwareIdentifier); |
| 333 | buf.append(",ipaddress:"); |
| 334 | buf.append(this.ipAddress); |
| 335 | buf.append(",nasId:"); |
| 336 | buf.append(this.nasId); |
| 337 | buf.append(",circuitId:"); |
| 338 | buf.append(this.circuitId); |
| 339 | buf.append(",remoteId:"); |
| 340 | buf.append(this.remoteId); |
| 341 | buf.append(",technologyProfileId:"); |
| 342 | buf.append(this.technologyProfileId); |
| 343 | buf.append(",upstreamBandwidthProfile:"); |
| 344 | buf.append(this.upstreamBandwidthProfile); |
| 345 | buf.append(",downstreamBandwidthProfile:"); |
| 346 | buf.append(this.downstreamBandwidthProfile); |
David K. Bainbridge | eda2b05 | 2017-07-12 09:41:04 -0700 | [diff] [blame] | 347 | buf.append(']'); |
| 348 | |
| 349 | return buf.toString(); |
| 350 | } |
| 351 | |
| 352 | } |