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