blob: f85ea0ffd20bb1e3498911db31115d253d9aeb9a [file] [log] [blame]
Amit Ghosh31939522018-08-16 13:28:21 +01001/*
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
17package org.opencord.olt;
18
19/**
20 * Class representing the identifier for a subscriber.
21 * It encapsulates the name of the logical port for the subscriber in
22 * ONOS.
23 * For e.g. if in ONOS you see
Matteo Scandoloe3b3e5a2019-12-17 17:47:38 -080024 * <pre>
25 * onos&gt; ports
Amit Ghosh31939522018-08-16 13:28:21 +010026 * id=of:00000000c0a83264, available=true, local-status=connected 3m48s ago, role=MASTER, mfr=VOLTHA Projectd,...
27 * port=32, state=enabled, type=fiber, speed=0 , adminState=enabled, portMac=08:00:00:00:00:20, portName=TWSH80808082
Matteo Scandoloe3b3e5a2019-12-17 17:47:38 -080028 * </pre>
Amit Ghosh31939522018-08-16 13:28:21 +010029 * the subscriber id would encapsulate the string "TWSH80808082"
30 */
31public class AccessSubscriberId {
32 // string representing the identifier
33 String id;
34
35 /**
36 * Creates an AccessSubscriberId with the passed id.
37 *
38 * @param id identifier of the subscriber
39 */
40 public AccessSubscriberId(String id) {
41 this.id = id;
42 }
43
44 /*
45 * (non-Javadoc)
46 *
47 * @see java.lang.Object#hashCode()
48 */
49 @Override
50 public int hashCode() {
51 final int prime = 31;
52 int result = 1;
53 result = prime * result + (this.id == null ? 0 : this.id.hashCode());
54
55 return result;
56 }
57
58 /*
59 * (non-Javadoc)
60 *
61 * @see java.lang.Object#equals(java.lang.Object)
62 */
63 @Override
64 public boolean equals(final Object obj) {
65 if (this == obj) {
66 return true;
67 }
68 if (obj == null) {
69 return false;
70 }
71 if (this.getClass() != obj.getClass()) {
72 return false;
73 }
74
75 final AccessSubscriberId other = (AccessSubscriberId) obj;
76 if (this.id == null) {
77 if (other.id != null) {
78 return false;
79 }
80 } else if (!this.id.equals(other.id)) {
81 return false;
82 }
83
84 return true;
85 }
86
87 /*
88 * (non-Javadoc)
89 *
90 * @see java.lang.Object#toString()
91 */
92 @Override
93 public String toString() {
94 return id;
95 }
96}