Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021-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.impl; |
| 18 | |
| 19 | import org.opencord.sadis.UniTagInformation; |
| 20 | |
| 21 | import java.util.Objects; |
| 22 | |
| 23 | /** |
| 24 | * SubscriberKey is used to identify the combination of a subscriber and a service. |
| 25 | */ |
| 26 | public class ServiceKey { |
| 27 | private AccessDevicePort port; |
| 28 | private UniTagInformation service; |
| 29 | |
| 30 | public ServiceKey(AccessDevicePort port, UniTagInformation service) { |
| 31 | this.port = port; |
| 32 | this.service = service; |
| 33 | } |
| 34 | |
| 35 | public AccessDevicePort getPort() { |
| 36 | return port; |
| 37 | } |
| 38 | |
| 39 | public void setPort(AccessDevicePort port) { |
| 40 | this.port = port; |
| 41 | } |
| 42 | |
| 43 | public UniTagInformation getService() { |
| 44 | return service; |
| 45 | } |
| 46 | |
| 47 | public void setService(UniTagInformation service) { |
| 48 | this.service = service; |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public String toString() { |
| 53 | return this.port.toString() + " - " + this.service.getServiceName(); |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public boolean equals(Object o) { |
| 58 | if (this == o) { |
| 59 | return true; |
| 60 | } |
| 61 | if (o == null || getClass() != o.getClass()) { |
| 62 | return false; |
| 63 | } |
| 64 | ServiceKey that = (ServiceKey) o; |
| 65 | boolean isPortEqual = Objects.equals(port, that.port); |
| 66 | boolean isServiceEqual = Objects.equals(service, that.service); |
| 67 | |
| 68 | return isPortEqual && isServiceEqual; |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public int hashCode() { |
| 73 | return Objects.hash(port, service); |
| 74 | } |
| 75 | } |