blob: 2ebe42ed20d7481b4bff08789dca62199b5c1b61 [file] [log] [blame]
David K. Bainbridgeeda2b052017-07-12 09:41:04 -07001/*
2 * Copyright 2017-present Open Networking Laboratory
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 */
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
Amit Ghoshc29c7a92017-08-01 09:59:13 +010056 protected SubscriberAndDeviceInformation() {
David K. Bainbridgeeda2b052017-07-12 09:41:04 -070057 }
58
59 public final String id() {
60 return this.id;
61 }
62
63 public final void setId(final String id) {
64 this.id = id;
65 }
66
67 public final VlanId sTag() {
68 return this.sTag;
69 }
70
71 public final void setSTag(final VlanId stag) {
72 this.sTag = stag;
73 }
74
75 public final VlanId cTag() {
76 return this.cTag;
77 }
78
79 public final void setCTag(final VlanId ctag) {
80 this.cTag = ctag;
81 }
82
83 public final String nasPortId() {
84 return this.nasPortId;
85 }
86
87 public final void setNasPortId(final String nasPortId) {
88 this.nasPortId = nasPortId;
89 }
90
91 public final int port() {
92 return this.port;
93 }
94
95 public final void setPort(final int port) {
96 this.port = port;
97 }
98
99 public final int slot() {
100 return this.slot;
101 }
102
103 public final void setSlot(final int slot) {
104 this.slot = slot;
105 }
106
107 public final MacAddress hardwareIdentifier() {
108 return this.hardwareIdentifier;
109 }
110
111 public final void setHardwareIdentifier(final MacAddress hardwareIdentifier) {
112 this.hardwareIdentifier = hardwareIdentifier;
113 }
114
Amit Ghosh38b232a2017-07-23 15:11:56 +0100115 public final Ip4Address ipAddress() {
116 return this.ipAddress;
117 }
118
119 public final void setIPAddress(final Ip4Address ipAddress) {
120 this.ipAddress = ipAddress;
121 }
122
123 public final String nasId() {
124 return this.nasId;
125 }
126
127 public final void setNasId(final String nasId) {
128 this.nasId = nasId;
129 }
David K. Bainbridgeeda2b052017-07-12 09:41:04 -0700130 /*
131 * (non-Javadoc)
132 *
133 * @see java.lang.Object#hashCode()
134 */
135 @Override
136 public int hashCode() {
137 final int prime = 31;
138 int result = 1;
139 result = prime * result + (this.cTag == null ? 0 : this.cTag.hashCode());
140 result = prime * result + (this.hardwareIdentifier == null ? 0 : this.hardwareIdentifier.hashCode());
141 result = prime * result + (this.id == null ? 0 : this.id.hashCode());
142 result = prime * result + (this.nasPortId == null ? 0 : this.nasPortId.hashCode());
143 result = prime * result + this.port;
144 result = prime * result + (this.sTag == null ? 0 : this.sTag.hashCode());
145 result = prime * result + this.slot;
Amit Ghosh38b232a2017-07-23 15:11:56 +0100146 result = prime * result + (this.ipAddress == null ? 0 : this.ipAddress.hashCode());
147 result = prime * result + (this.nasId == null ? 0 : this.nasId.hashCode());
David K. Bainbridgeeda2b052017-07-12 09:41:04 -0700148 return result;
149 }
150
151 /*
152 * (non-Javadoc)
153 *
154 * @see java.lang.Object#equals(java.lang.Object)
155 */
156 @Override
157 public boolean equals(final Object obj) {
158 if (this == obj) {
159 return true;
160 }
161 if (obj == null) {
162 return false;
163 }
164 if (this.getClass() != obj.getClass()) {
165 return false;
166 }
167 final SubscriberAndDeviceInformation other = (SubscriberAndDeviceInformation) obj;
168 if (this.cTag == null) {
169 if (other.cTag != null) {
170 return false;
171 }
172 } else if (!this.cTag.equals(other.cTag)) {
173 return false;
174 }
175 if (this.hardwareIdentifier == null) {
176 if (other.hardwareIdentifier != null) {
177 return false;
178 }
179 } else if (!this.hardwareIdentifier.equals(other.hardwareIdentifier)) {
180 return false;
181 }
182 if (this.id == null) {
183 if (other.id != null) {
184 return false;
185 }
186 } else if (!this.id.equals(other.id)) {
187 return false;
188 }
189 if (this.nasPortId == null) {
190 if (other.nasPortId != null) {
191 return false;
192 }
193 } else if (!this.nasPortId.equals(other.nasPortId)) {
194 return false;
195 }
Amit Ghosh38b232a2017-07-23 15:11:56 +0100196 if (this.nasId == null) {
197 if (other.nasId != null) {
198 return false;
199 }
200 } else if (!this.nasId.equals(other.nasId)) {
201 return false;
202 }
203 if (this.ipAddress == null) {
204 if (other.ipAddress != null) {
205 return false;
206 }
207 } else if (!this.ipAddress.equals(other.ipAddress())) {
208 return false;
209 }
David K. Bainbridgeeda2b052017-07-12 09:41:04 -0700210 if (this.port != other.port) {
211 return false;
212 }
213 if (this.sTag == null) {
214 if (other.sTag != null) {
215 return false;
216 }
217 } else if (!this.sTag.equals(other.sTag)) {
218 return false;
219 }
220 if (this.slot != other.slot) {
221 return false;
222 }
223 return true;
224 }
225
226 /*
227 * (non-Javadoc)
228 *
229 * @see java.lang.Object#toString()
230 */
231 @Override
232 public String toString() {
233 final StringBuilder buf = new StringBuilder();
234 buf.append('[');
235 buf.append("id:");
236 buf.append(this.id);
237 buf.append(",cTag:");
238 buf.append(this.cTag);
239 buf.append(",sTag:");
240 buf.append(this.sTag);
241 buf.append(",nasPortId:");
242 buf.append(this.nasPortId);
243 buf.append(",port:");
244 buf.append(this.port);
245 buf.append(",slot:");
246 buf.append(this.slot);
247 buf.append(",hardwareIdentifier:");
248 buf.append(this.hardwareIdentifier);
Amit Ghosh38b232a2017-07-23 15:11:56 +0100249 buf.append(",ipaddress:");
250 buf.append(this.ipAddress);
251 buf.append(",nasId:");
252 buf.append(this.nasId);
David K. Bainbridgeeda2b052017-07-12 09:41:04 -0700253 buf.append(']');
254
255 return buf.toString();
256 }
257
258}