Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Foundation |
| 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 | |
| 18 | import com.fasterxml.jackson.annotation.JsonProperty; |
| 19 | import org.onlab.packet.VlanId; |
| 20 | |
Andrea Campanella | 092df20 | 2021-11-29 10:38:45 -0800 | [diff] [blame^] | 21 | import java.util.Objects; |
| 22 | |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 23 | /** |
| 24 | * Represents a unit of information about a service. |
| 25 | */ |
| 26 | public final class UniTagInformation { |
| 27 | |
| 28 | @JsonProperty(value = "uniTagMatch") |
Matteo Scandolo | c1e7272 | 2020-03-20 12:53:14 -0700 | [diff] [blame] | 29 | private VlanId uniTagMatch = VlanId.vlanId(VlanId.NO_VID); |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 30 | |
| 31 | @JsonProperty(value = "ponCTag") |
| 32 | private VlanId ponCTag; |
| 33 | |
| 34 | @JsonProperty(value = "ponSTag") |
| 35 | private VlanId ponSTag; |
| 36 | |
| 37 | @JsonProperty(value = "usPonCTagPriority") |
| 38 | private int usPonCTagPriority = -1; |
| 39 | |
| 40 | @JsonProperty(value = "usPonSTagPriority") |
| 41 | private int usPonSTagPriority = -1; |
| 42 | |
| 43 | @JsonProperty(value = "dsPonCTagPriority") |
| 44 | private int dsPonCTagPriority = -1; |
| 45 | |
| 46 | @JsonProperty(value = "dsPonSTagPriority") |
| 47 | private int dsPonSTagPriority = -1; |
| 48 | |
| 49 | @JsonProperty(value = "technologyProfileId") |
| 50 | private int technologyProfileId = -1; |
| 51 | |
| 52 | @JsonProperty(value = "upstreamBandwidthProfile") |
| 53 | private String upstreamBandwidthProfile; |
| 54 | |
| 55 | @JsonProperty(value = "downstreamBandwidthProfile") |
| 56 | private String downstreamBandwidthProfile; |
| 57 | |
yasin sapli | 2c93ddb | 2021-06-11 17:46:26 +0300 | [diff] [blame] | 58 | @JsonProperty(value = "upstreamOltBandwidthProfile") |
| 59 | private String upstreamOltBandwidthProfile; |
| 60 | |
| 61 | @JsonProperty(value = "downstreamOltBandwidthProfile") |
| 62 | private String downstreamOltBandwidthProfile; |
| 63 | |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 64 | @JsonProperty(value = "serviceName") |
| 65 | private String serviceName; |
| 66 | |
| 67 | @JsonProperty(value = "enableMacLearning") |
| 68 | private boolean enableMacLearning = false; |
| 69 | |
| 70 | @JsonProperty(value = "configuredMacAddress") |
| 71 | private String configuredMacAddress; |
| 72 | |
| 73 | @JsonProperty(value = "isDhcpRequired") |
| 74 | private boolean isDhcpRequired; |
| 75 | |
| 76 | @JsonProperty(value = "isIgmpRequired") |
| 77 | private boolean isIgmpRequired; |
| 78 | |
| 79 | public UniTagInformation() { |
| 80 | |
| 81 | } |
yasin sapli | 2c93ddb | 2021-06-11 17:46:26 +0300 | [diff] [blame] | 82 | //CHECKSTYLE:OFF |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 83 | private UniTagInformation(final VlanId uniTagMatch, final VlanId ponCTag, final VlanId ponSTag, |
| 84 | final int usPonCTagPriority, final int usPonSTagPriority, |
| 85 | final int dsPonCTagPriority, final int dsPonSTagPriority, |
| 86 | final int technologyProfileId, |
yasin sapli | 2c93ddb | 2021-06-11 17:46:26 +0300 | [diff] [blame] | 87 | final String upstreamBandwidthProfile, |
| 88 | final String downstreamBandwidthProfile, |
| 89 | final String upstreamOltBandwidthProfile, |
| 90 | final String downstreamOltBandwidthProfile, |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 91 | final String serviceName, final boolean enableMacLearning, |
| 92 | final String configuredMacAddress, final boolean isDhcpRequired, |
| 93 | final boolean isIgmpRequired) { |
| 94 | this.uniTagMatch = uniTagMatch; |
| 95 | this.ponCTag = ponCTag; |
| 96 | this.ponSTag = ponSTag; |
| 97 | this.usPonCTagPriority = usPonCTagPriority; |
| 98 | this.usPonSTagPriority = usPonSTagPriority; |
| 99 | this.dsPonCTagPriority = dsPonCTagPriority; |
| 100 | this.dsPonSTagPriority = dsPonSTagPriority; |
| 101 | this.technologyProfileId = technologyProfileId; |
| 102 | this.upstreamBandwidthProfile = upstreamBandwidthProfile; |
| 103 | this.downstreamBandwidthProfile = downstreamBandwidthProfile; |
yasin sapli | 2c93ddb | 2021-06-11 17:46:26 +0300 | [diff] [blame] | 104 | this.upstreamOltBandwidthProfile = upstreamOltBandwidthProfile; |
| 105 | this.downstreamOltBandwidthProfile = downstreamOltBandwidthProfile; |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 106 | this.serviceName = serviceName; |
| 107 | this.enableMacLearning = enableMacLearning; |
| 108 | this.configuredMacAddress = configuredMacAddress; |
| 109 | this.isDhcpRequired = isDhcpRequired; |
| 110 | this.isIgmpRequired = isIgmpRequired; |
| 111 | } |
yasin sapli | 2c93ddb | 2021-06-11 17:46:26 +0300 | [diff] [blame] | 112 | //CHECKSTYLE:ON |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 113 | |
| 114 | public final VlanId getUniTagMatch() { |
| 115 | return uniTagMatch; |
| 116 | } |
| 117 | |
| 118 | public final VlanId getPonCTag() { |
| 119 | return ponCTag; |
| 120 | } |
| 121 | |
| 122 | public final VlanId getPonSTag() { |
| 123 | return ponSTag; |
| 124 | } |
| 125 | |
| 126 | public final int getUsPonCTagPriority() { |
| 127 | return usPonCTagPriority; |
| 128 | } |
| 129 | |
| 130 | public final int getUsPonSTagPriority() { |
| 131 | return usPonSTagPriority; |
| 132 | } |
| 133 | |
| 134 | public final int getDsPonCTagPriority() { |
| 135 | return dsPonCTagPriority; |
| 136 | } |
| 137 | |
| 138 | public final int getDsPonSTagPriority() { |
| 139 | return dsPonSTagPriority; |
| 140 | } |
| 141 | |
| 142 | public final int getTechnologyProfileId() { |
| 143 | return technologyProfileId; |
| 144 | } |
| 145 | |
| 146 | public final String getUpstreamBandwidthProfile() { |
| 147 | return upstreamBandwidthProfile; |
| 148 | } |
| 149 | |
| 150 | public final String getDownstreamBandwidthProfile() { |
| 151 | return downstreamBandwidthProfile; |
| 152 | } |
| 153 | |
yasin sapli | 2c93ddb | 2021-06-11 17:46:26 +0300 | [diff] [blame] | 154 | public final String getUpstreamOltBandwidthProfile() { |
| 155 | return upstreamOltBandwidthProfile; |
| 156 | } |
| 157 | |
| 158 | public final String getDownstreamOltBandwidthProfile() { |
| 159 | return downstreamOltBandwidthProfile; |
| 160 | } |
| 161 | |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 162 | public final String getServiceName() { |
| 163 | return serviceName; |
| 164 | } |
| 165 | |
| 166 | public final boolean getEnableMacLearning() { |
| 167 | return enableMacLearning; |
| 168 | } |
| 169 | |
| 170 | public final String getConfiguredMacAddress() { |
| 171 | return configuredMacAddress; |
| 172 | } |
| 173 | |
| 174 | public final boolean getIsDhcpRequired() { |
| 175 | return isDhcpRequired; |
| 176 | } |
| 177 | |
| 178 | public final boolean getIsIgmpRequired() { |
| 179 | return isIgmpRequired; |
| 180 | } |
| 181 | |
| 182 | @Override |
| 183 | public boolean equals(Object o) { |
| 184 | if (this == o) { |
| 185 | return true; |
| 186 | } |
| 187 | if (o == null || getClass() != o.getClass()) { |
| 188 | return false; |
| 189 | } |
| 190 | |
| 191 | UniTagInformation that = (UniTagInformation) o; |
| 192 | |
Andrea Campanella | 092df20 | 2021-11-29 10:38:45 -0800 | [diff] [blame^] | 193 | if (!Objects.equals(uniTagMatch, that.uniTagMatch)) { |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 194 | return false; |
| 195 | } |
| 196 | if (technologyProfileId != that.technologyProfileId) { |
| 197 | return false; |
| 198 | } |
Andrea Campanella | 092df20 | 2021-11-29 10:38:45 -0800 | [diff] [blame^] | 199 | if (!Objects.equals(ponCTag, that.ponCTag)) { |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 200 | return false; |
| 201 | } |
Andrea Campanella | 092df20 | 2021-11-29 10:38:45 -0800 | [diff] [blame^] | 202 | if (!Objects.equals(ponSTag, that.ponSTag)) { |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 203 | return false; |
| 204 | } |
| 205 | if (usPonCTagPriority != that.usPonCTagPriority) { |
| 206 | return false; |
| 207 | } |
| 208 | if (usPonSTagPriority != that.usPonSTagPriority) { |
| 209 | return false; |
| 210 | } |
| 211 | if (dsPonCTagPriority != that.dsPonCTagPriority) { |
| 212 | return false; |
| 213 | } |
| 214 | if (dsPonSTagPriority != that.dsPonSTagPriority) { |
| 215 | return false; |
| 216 | } |
| 217 | if (enableMacLearning != that.enableMacLearning) { |
| 218 | return false; |
| 219 | } |
Andrea Campanella | 092df20 | 2021-11-29 10:38:45 -0800 | [diff] [blame^] | 220 | if (!Objects.equals(configuredMacAddress, that.configuredMacAddress)) { |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 221 | return false; |
| 222 | } |
| 223 | if (isDhcpRequired != that.isDhcpRequired) { |
| 224 | return false; |
| 225 | } |
| 226 | if (isIgmpRequired != that.isIgmpRequired) { |
| 227 | return false; |
| 228 | } |
| 229 | if (upstreamBandwidthProfile != null ? !upstreamBandwidthProfile.equals(that.upstreamBandwidthProfile) : |
| 230 | that.upstreamBandwidthProfile != null) { |
| 231 | return false; |
| 232 | } |
| 233 | if (downstreamBandwidthProfile != null ? !downstreamBandwidthProfile.equals(that.downstreamBandwidthProfile) : |
| 234 | that.downstreamBandwidthProfile != null) { |
| 235 | return false; |
| 236 | } |
yasin sapli | 2c93ddb | 2021-06-11 17:46:26 +0300 | [diff] [blame] | 237 | if (upstreamOltBandwidthProfile != null ? |
| 238 | !upstreamOltBandwidthProfile.equals(that.upstreamOltBandwidthProfile) : |
| 239 | that.upstreamOltBandwidthProfile != null) { |
| 240 | return false; |
| 241 | } |
| 242 | if (downstreamOltBandwidthProfile != null ? |
| 243 | !downstreamOltBandwidthProfile.equals(that.downstreamOltBandwidthProfile) : |
| 244 | that.downstreamOltBandwidthProfile != null) { |
| 245 | return false; |
| 246 | } |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 247 | return serviceName != null ? serviceName.equals(that.serviceName) : that.serviceName == null; |
| 248 | } |
| 249 | |
| 250 | @Override |
| 251 | public int hashCode() { |
| 252 | int result = uniTagMatch != null ? uniTagMatch.hashCode() : 0; |
| 253 | result = 31 * result + (ponCTag != null ? ponCTag.hashCode() : 0); |
| 254 | result = 31 * result + (ponSTag != null ? ponSTag.hashCode() : 0); |
| 255 | result = 31 * result + usPonCTagPriority; |
| 256 | result = 31 * result + usPonSTagPriority; |
| 257 | result = 31 * result + dsPonCTagPriority; |
| 258 | result = 31 * result + dsPonSTagPriority; |
| 259 | result = 31 * result + technologyProfileId; |
| 260 | result = 31 * result + (upstreamBandwidthProfile != null ? upstreamBandwidthProfile.hashCode() : 0); |
| 261 | result = 31 * result + (downstreamBandwidthProfile != null ? downstreamBandwidthProfile.hashCode() : 0); |
yasin sapli | 2c93ddb | 2021-06-11 17:46:26 +0300 | [diff] [blame] | 262 | result = 31 * result + (upstreamOltBandwidthProfile != null ? upstreamOltBandwidthProfile.hashCode() : 0); |
| 263 | result = 31 * result + (downstreamOltBandwidthProfile != null ? downstreamOltBandwidthProfile.hashCode() : 0); |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 264 | result = 31 * result + (serviceName != null ? serviceName.hashCode() : 0); |
| 265 | result = 31 * result + (enableMacLearning ? 1 : 0); |
| 266 | result = 31 * result + (configuredMacAddress != null ? configuredMacAddress.hashCode() : 0); |
| 267 | result = 31 * result + (isDhcpRequired ? 1 : 0); |
| 268 | result = 31 * result + (isIgmpRequired ? 1 : 0); |
| 269 | return result; |
| 270 | } |
| 271 | |
| 272 | @Override |
| 273 | public String toString() { |
| 274 | final StringBuilder sb = new StringBuilder("UniTagInformation{"); |
| 275 | sb.append("uniTagMatch=").append(uniTagMatch); |
| 276 | sb.append(", ponCTag=").append(ponCTag); |
| 277 | sb.append(", ponSTag=").append(ponSTag); |
| 278 | sb.append(", usPonCTagPriority=").append(usPonCTagPriority); |
| 279 | sb.append(", usPonSTagPriority=").append(usPonSTagPriority); |
| 280 | sb.append(", dsPonCTagPriority=").append(dsPonCTagPriority); |
| 281 | sb.append(", dsPonSTagPriority=").append(dsPonSTagPriority); |
| 282 | sb.append(", technologyProfileId=").append(technologyProfileId); |
| 283 | sb.append(", enableMacLearning=").append(enableMacLearning); |
| 284 | sb.append(", upstreamBandwidthProfile='").append(upstreamBandwidthProfile).append('\''); |
| 285 | sb.append(", downstreamBandwidthProfile='").append(downstreamBandwidthProfile).append('\''); |
yasin sapli | 2c93ddb | 2021-06-11 17:46:26 +0300 | [diff] [blame] | 286 | sb.append(", upstreamOltBandwidthProfile='").append(upstreamOltBandwidthProfile).append('\''); |
| 287 | sb.append(", downstreamOltBandwidthProfile='").append(downstreamOltBandwidthProfile).append('\''); |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 288 | sb.append(", serviceName='").append(serviceName).append('\''); |
| 289 | sb.append(", configuredMacAddress='").append(configuredMacAddress).append('\''); |
| 290 | sb.append(", isDhcpRequired=").append(isDhcpRequired); |
| 291 | sb.append(", isIgmpRequired=").append(isIgmpRequired); |
| 292 | sb.append('}'); |
| 293 | return sb.toString(); |
| 294 | } |
| 295 | |
| 296 | public static final class Builder { |
| 297 | |
| 298 | private VlanId uniTagMatch; |
| 299 | private VlanId ponCTag; |
| 300 | private VlanId ponSTag; |
Gamze Abaka | 7f987c0 | 2020-02-03 08:19:32 +0000 | [diff] [blame] | 301 | private int usPonCTagPriority = -1; |
| 302 | private int usPonSTagPriority = -1; |
| 303 | private int dsPonCTagPriority = -1; |
| 304 | private int dsPonSTagPriority = -1; |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 305 | private int technologyProfileId; |
| 306 | private String upstreamBandwidthProfile; |
| 307 | private String downstreamBandwidthProfile; |
yasin sapli | 2c93ddb | 2021-06-11 17:46:26 +0300 | [diff] [blame] | 308 | private String upstreamOltBandwidthProfile; |
| 309 | private String downstreamOltBandwidthProfile; |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 310 | private String serviceName; |
| 311 | private boolean enableMacLearning; |
| 312 | private String configuredMacAddress; |
| 313 | private boolean isDhcpRequired; |
| 314 | private boolean isIgmpRequired; |
| 315 | |
| 316 | public final Builder setUniTagMatch(final VlanId uniTagMatch) { |
| 317 | this.uniTagMatch = uniTagMatch; |
| 318 | return this; |
| 319 | } |
| 320 | |
| 321 | public final Builder setPonCTag(final VlanId ponCTag) { |
| 322 | this.ponCTag = ponCTag; |
| 323 | return this; |
| 324 | } |
| 325 | |
| 326 | public final Builder setPonSTag(final VlanId ponSTag) { |
| 327 | this.ponSTag = ponSTag; |
| 328 | return this; |
| 329 | } |
| 330 | |
| 331 | public final Builder setUsPonCTagPriority(final int usPonCTagPriority) { |
| 332 | this.usPonCTagPriority = usPonCTagPriority; |
| 333 | return this; |
| 334 | } |
| 335 | |
| 336 | public final Builder setUsPonSTagPriority(final int usPonSTagPriority) { |
| 337 | this.usPonSTagPriority = usPonSTagPriority; |
| 338 | return this; |
| 339 | } |
| 340 | |
| 341 | public final Builder setDsPonCTagPriority(final int dsPonCTagPriority) { |
| 342 | this.dsPonCTagPriority = dsPonCTagPriority; |
| 343 | return this; |
| 344 | } |
| 345 | |
| 346 | public final Builder setDsPonSTagPriority(final int dsPonSTagPriority) { |
| 347 | this.dsPonSTagPriority = dsPonSTagPriority; |
| 348 | return this; |
| 349 | } |
| 350 | |
| 351 | public final Builder setTechnologyProfileId(final int technologyProfileId) { |
| 352 | this.technologyProfileId = technologyProfileId; |
| 353 | return this; |
| 354 | } |
| 355 | |
| 356 | public final Builder setUpstreamBandwidthProfile(final String upstreamBandwidthProfile) { |
| 357 | this.upstreamBandwidthProfile = upstreamBandwidthProfile; |
| 358 | return this; |
| 359 | } |
| 360 | |
| 361 | public final Builder setDownstreamBandwidthProfile(final String downstreamBandwidthProfile) { |
| 362 | this.downstreamBandwidthProfile = downstreamBandwidthProfile; |
| 363 | return this; |
| 364 | } |
| 365 | |
yasin sapli | 2c93ddb | 2021-06-11 17:46:26 +0300 | [diff] [blame] | 366 | public final Builder setUpstreamOltBandwidthProfile(final String upstreamOltBandwidthProfile) { |
| 367 | this.upstreamOltBandwidthProfile = upstreamOltBandwidthProfile; |
| 368 | return this; |
| 369 | } |
| 370 | |
| 371 | public final Builder setDownstreamOltBandwidthProfile(final String downstreamOltBandwidthProfile) { |
| 372 | this.downstreamOltBandwidthProfile = downstreamOltBandwidthProfile; |
| 373 | return this; |
| 374 | } |
| 375 | |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 376 | public final Builder setServiceName(final String serviceName) { |
| 377 | this.serviceName = serviceName; |
| 378 | return this; |
| 379 | } |
| 380 | |
| 381 | public final Builder setEnableMacLearning(final boolean enableMacLearning) { |
| 382 | this.enableMacLearning = enableMacLearning; |
| 383 | return this; |
| 384 | } |
| 385 | |
| 386 | public final Builder setConfiguredMacAddress(final String configuredMacAddress) { |
| 387 | this.configuredMacAddress = configuredMacAddress; |
| 388 | return this; |
| 389 | } |
| 390 | |
| 391 | public final Builder setIsDhcpRequired(final boolean isDhcpRequired) { |
| 392 | this.isDhcpRequired = isDhcpRequired; |
| 393 | return this; |
| 394 | } |
| 395 | |
| 396 | public final Builder setIsIgmpRequired(final boolean isIgmpRequired) { |
| 397 | this.isIgmpRequired = isIgmpRequired; |
| 398 | return this; |
| 399 | } |
| 400 | |
| 401 | public final UniTagInformation build() { |
| 402 | return new UniTagInformation(this.uniTagMatch, this.ponCTag, |
| 403 | this.ponSTag, this.usPonCTagPriority, this.usPonSTagPriority, |
| 404 | this.dsPonCTagPriority, this.dsPonSTagPriority, this.technologyProfileId, |
yasin sapli | 2c93ddb | 2021-06-11 17:46:26 +0300 | [diff] [blame] | 405 | this.upstreamBandwidthProfile, this.downstreamBandwidthProfile, |
| 406 | this.upstreamOltBandwidthProfile, this.downstreamOltBandwidthProfile, |
| 407 | this.serviceName, this.enableMacLearning, |
| 408 | this.configuredMacAddress, this.isDhcpRequired, this.isIgmpRequired); |
Matteo Scandolo | 198aef9 | 2020-01-08 00:43:17 +0000 | [diff] [blame] | 409 | } |
| 410 | } |
| 411 | } |