blob: 80ca6851272d69406267f71cff9dc2c38c484163 [file] [log] [blame]
David K. Bainbridgeeda2b052017-07-12 09:41:04 -07001/*
Brian O'Connor180c1092017-08-03 22:46:14 -07002 * Copyright 2017-present Open Networking Foundation
David K. Bainbridgeeda2b052017-07-12 09:41:04 -07003 *
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 */
16package org.opencord.sadis;
17
Amit Ghosh38b232a2017-07-23 15:11:56 +010018import org.onlab.packet.Ip4Address;
David K. Bainbridgeeda2b052017-07-12 09:41:04 -070019import org.onlab.packet.MacAddress;
20import org.onlab.packet.VlanId;
21
22import com.fasterxml.jackson.annotation.JsonProperty;
23
24/**
25 * Represents a unit of information about a subscriber or access device.
26 */
27public class SubscriberAndDeviceInformation {
28
29 @JsonProperty(value = "id")
30 String id;
31
32 @JsonProperty(value = "sTag")
33 VlanId sTag;
34
35 @JsonProperty(value = "cTag")
36 VlanId cTag;
37
38 @JsonProperty(value = "nasPortId")
39 String nasPortId;
40
41 @JsonProperty(value = "port")
Amit Ghosh38b232a2017-07-23 15:11:56 +010042 int port = -1;
David K. Bainbridgeeda2b052017-07-12 09:41:04 -070043
44 @JsonProperty(value = "slot")
Amit Ghosh38b232a2017-07-23 15:11:56 +010045 int slot = -1;
David K. Bainbridgeeda2b052017-07-12 09:41:04 -070046
47 @JsonProperty(value = "hardwareIdentifier")
48 MacAddress hardwareIdentifier;
49
Amit Ghosh38b232a2017-07-23 15:11:56 +010050 @JsonProperty(value = "ipAddress")
51 Ip4Address ipAddress;
52
53 @JsonProperty(value = "nasId")
54 String nasId;
55
David K. Bainbridge8bf98e02017-08-07 10:41:56 -070056 @JsonProperty(value = "circuitId")
57 String circuitId;
58
59 @JsonProperty(value = "remoteId")
60 String remoteId;
61
Amit Ghoshc29c7a92017-08-01 09:59:13 +010062 protected SubscriberAndDeviceInformation() {
David K. Bainbridgeeda2b052017-07-12 09:41:04 -070063 }
64
65 public final String id() {
66 return this.id;
67 }
68
69 public final void setId(final String id) {
70 this.id = id;
71 }
72
73 public final VlanId sTag() {
74 return this.sTag;
75 }
76
77 public final void setSTag(final VlanId stag) {
78 this.sTag = stag;
79 }
80
81 public final VlanId cTag() {
82 return this.cTag;
83 }
84
85 public final void setCTag(final VlanId ctag) {
86 this.cTag = ctag;
87 }
88
89 public final String nasPortId() {
90 return this.nasPortId;
91 }
92
93 public final void setNasPortId(final String nasPortId) {
94 this.nasPortId = nasPortId;
95 }
96
97 public final int port() {
98 return this.port;
99 }
100
101 public final void setPort(final int port) {
102 this.port = port;
103 }
104
105 public final int slot() {
106 return this.slot;
107 }
108
109 public final void setSlot(final int slot) {
110 this.slot = slot;
111 }
112
113 public final MacAddress hardwareIdentifier() {
114 return this.hardwareIdentifier;
115 }
116
117 public final void setHardwareIdentifier(final MacAddress hardwareIdentifier) {
118 this.hardwareIdentifier = hardwareIdentifier;
119 }
120
Amit Ghosh38b232a2017-07-23 15:11:56 +0100121 public final Ip4Address ipAddress() {
122 return this.ipAddress;
123 }
124
125 public final void setIPAddress(final Ip4Address ipAddress) {
126 this.ipAddress = ipAddress;
127 }
128
129 public final String nasId() {
130 return this.nasId;
131 }
132
133 public final void setNasId(final String nasId) {
134 this.nasId = nasId;
135 }
David K. Bainbridge8bf98e02017-08-07 10:41:56 -0700136
137 public final String circuitId() {
138 return this.circuitId;
139 }
140
141 public final void setCircuitId(final String circuitId) {
142 this.circuitId = circuitId;
143 }
144
145 public final String remoteId() {
146 return this.remoteId;
147 }
148
149 public final void setRemoteId(final String remoteId) {
150 this.remoteId = remoteId;
151 }
152
David K. Bainbridgeeda2b052017-07-12 09:41:04 -0700153 /*
154 * (non-Javadoc)
155 *
156 * @see java.lang.Object#hashCode()
157 */
158 @Override
159 public int hashCode() {
160 final int prime = 31;
161 int result = 1;
162 result = prime * result + (this.cTag == null ? 0 : this.cTag.hashCode());
163 result = prime * result + (this.hardwareIdentifier == null ? 0 : this.hardwareIdentifier.hashCode());
164 result = prime * result + (this.id == null ? 0 : this.id.hashCode());
165 result = prime * result + (this.nasPortId == null ? 0 : this.nasPortId.hashCode());
166 result = prime * result + this.port;
167 result = prime * result + (this.sTag == null ? 0 : this.sTag.hashCode());
168 result = prime * result + this.slot;
Amit Ghosh38b232a2017-07-23 15:11:56 +0100169 result = prime * result + (this.ipAddress == null ? 0 : this.ipAddress.hashCode());
170 result = prime * result + (this.nasId == null ? 0 : this.nasId.hashCode());
David K. Bainbridge8bf98e02017-08-07 10:41:56 -0700171 result = prime + result + (this.circuitId == null ? 0 : this.circuitId.hashCode());
172 result = prime + result + (this.remoteId == null ? 0 : this.remoteId.hashCode());
David K. Bainbridgeeda2b052017-07-12 09:41:04 -0700173 return result;
174 }
175
176 /*
177 * (non-Javadoc)
178 *
179 * @see java.lang.Object#equals(java.lang.Object)
180 */
181 @Override
182 public boolean equals(final Object obj) {
183 if (this == obj) {
184 return true;
185 }
186 if (obj == null) {
187 return false;
188 }
189 if (this.getClass() != obj.getClass()) {
190 return false;
191 }
192 final SubscriberAndDeviceInformation other = (SubscriberAndDeviceInformation) obj;
193 if (this.cTag == null) {
194 if (other.cTag != null) {
195 return false;
196 }
197 } else if (!this.cTag.equals(other.cTag)) {
198 return false;
199 }
200 if (this.hardwareIdentifier == null) {
201 if (other.hardwareIdentifier != null) {
202 return false;
203 }
204 } else if (!this.hardwareIdentifier.equals(other.hardwareIdentifier)) {
205 return false;
206 }
207 if (this.id == null) {
208 if (other.id != null) {
209 return false;
210 }
211 } else if (!this.id.equals(other.id)) {
212 return false;
213 }
214 if (this.nasPortId == null) {
215 if (other.nasPortId != null) {
216 return false;
217 }
218 } else if (!this.nasPortId.equals(other.nasPortId)) {
219 return false;
220 }
Amit Ghosh38b232a2017-07-23 15:11:56 +0100221 if (this.nasId == null) {
222 if (other.nasId != null) {
223 return false;
224 }
225 } else if (!this.nasId.equals(other.nasId)) {
226 return false;
227 }
228 if (this.ipAddress == null) {
229 if (other.ipAddress != null) {
230 return false;
231 }
232 } else if (!this.ipAddress.equals(other.ipAddress())) {
233 return false;
234 }
David K. Bainbridgeeda2b052017-07-12 09:41:04 -0700235 if (this.port != other.port) {
236 return false;
237 }
238 if (this.sTag == null) {
239 if (other.sTag != null) {
240 return false;
241 }
242 } else if (!this.sTag.equals(other.sTag)) {
243 return false;
244 }
245 if (this.slot != other.slot) {
246 return false;
247 }
David K. Bainbridge8bf98e02017-08-07 10:41:56 -0700248 if (this.circuitId == null) {
249 if (other.circuitId != null) {
250 return false;
251 }
252 } else if (!this.circuitId.equals(other.circuitId)) {
253 return false;
254 }
255 if (this.remoteId == null) {
256 if (other.remoteId != null) {
257 return false;
258 }
259 } else if (!this.remoteId.equals(other.remoteId)) {
260 return false;
261 }
David K. Bainbridgeeda2b052017-07-12 09:41:04 -0700262 return true;
263 }
264
265 /*
266 * (non-Javadoc)
267 *
268 * @see java.lang.Object#toString()
269 */
270 @Override
271 public String toString() {
272 final StringBuilder buf = new StringBuilder();
273 buf.append('[');
274 buf.append("id:");
275 buf.append(this.id);
276 buf.append(",cTag:");
277 buf.append(this.cTag);
278 buf.append(",sTag:");
279 buf.append(this.sTag);
280 buf.append(",nasPortId:");
281 buf.append(this.nasPortId);
282 buf.append(",port:");
283 buf.append(this.port);
284 buf.append(",slot:");
285 buf.append(this.slot);
286 buf.append(",hardwareIdentifier:");
287 buf.append(this.hardwareIdentifier);
Amit Ghosh38b232a2017-07-23 15:11:56 +0100288 buf.append(",ipaddress:");
289 buf.append(this.ipAddress);
290 buf.append(",nasId:");
291 buf.append(this.nasId);
David K. Bainbridge8bf98e02017-08-07 10:41:56 -0700292 buf.append(",circuitId:");
293 buf.append(this.circuitId);
294 buf.append(",remoteId:");
295 buf.append(this.remoteId);
David K. Bainbridgeeda2b052017-07-12 09:41:04 -0700296 buf.append(']');
297
298 return buf.toString();
299 }
300
301}