Amit Ghosh | 3193952 | 2018-08-16 13:28:21 +0100 | [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 | |
| 17 | package 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 |
| 24 | * onos> ports |
| 25 | * id=of:00000000c0a83264, available=true, local-status=connected 3m48s ago, role=MASTER, mfr=VOLTHA Projectd,... |
| 26 | * port=32, state=enabled, type=fiber, speed=0 , adminState=enabled, portMac=08:00:00:00:00:20, portName=TWSH80808082 |
| 27 | * |
| 28 | * the subscriber id would encapsulate the string "TWSH80808082" |
| 29 | */ |
| 30 | public class AccessSubscriberId { |
| 31 | // string representing the identifier |
| 32 | String id; |
| 33 | |
| 34 | /** |
| 35 | * Creates an AccessSubscriberId with the passed id. |
| 36 | * |
| 37 | * @param id identifier of the subscriber |
| 38 | */ |
| 39 | public AccessSubscriberId(String id) { |
| 40 | this.id = id; |
| 41 | } |
| 42 | |
| 43 | /* |
| 44 | * (non-Javadoc) |
| 45 | * |
| 46 | * @see java.lang.Object#hashCode() |
| 47 | */ |
| 48 | @Override |
| 49 | public int hashCode() { |
| 50 | final int prime = 31; |
| 51 | int result = 1; |
| 52 | result = prime * result + (this.id == null ? 0 : this.id.hashCode()); |
| 53 | |
| 54 | return result; |
| 55 | } |
| 56 | |
| 57 | /* |
| 58 | * (non-Javadoc) |
| 59 | * |
| 60 | * @see java.lang.Object#equals(java.lang.Object) |
| 61 | */ |
| 62 | @Override |
| 63 | public boolean equals(final Object obj) { |
| 64 | if (this == obj) { |
| 65 | return true; |
| 66 | } |
| 67 | if (obj == null) { |
| 68 | return false; |
| 69 | } |
| 70 | if (this.getClass() != obj.getClass()) { |
| 71 | return false; |
| 72 | } |
| 73 | |
| 74 | final AccessSubscriberId other = (AccessSubscriberId) obj; |
| 75 | if (this.id == null) { |
| 76 | if (other.id != null) { |
| 77 | return false; |
| 78 | } |
| 79 | } else if (!this.id.equals(other.id)) { |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | return true; |
| 84 | } |
| 85 | |
| 86 | /* |
| 87 | * (non-Javadoc) |
| 88 | * |
| 89 | * @see java.lang.Object#toString() |
| 90 | */ |
| 91 | @Override |
| 92 | public String toString() { |
| 93 | return id; |
| 94 | } |
| 95 | } |