slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2015-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 | */ |
| 16 | |
| 17 | package org.onosproject.xran.identifiers; |
| 18 | |
| 19 | import org.onosproject.xran.codecs.api.ECGI; |
| 20 | import org.onosproject.xran.codecs.api.MMEUES1APID; |
| 21 | import org.onosproject.xran.entities.RnibCell; |
| 22 | import org.onosproject.xran.entities.RnibUe; |
| 23 | |
| 24 | public class LinkId { |
| 25 | private ECGI source; |
| 26 | private MMEUES1APID destination; |
| 27 | |
| 28 | public LinkId(ECGI source, MMEUES1APID destination) { |
| 29 | this.source = source; |
| 30 | this.destination = destination; |
| 31 | } |
| 32 | |
| 33 | public static LinkId valueOf(RnibCell cell, RnibUe ue) { |
| 34 | return new LinkId(cell.getEcgi(), ue.getMmeS1apId()); |
| 35 | } |
| 36 | |
| 37 | public ECGI getSource() { |
| 38 | return source; |
| 39 | } |
| 40 | |
| 41 | public void setSource(ECGI source) { |
| 42 | this.source = source; |
| 43 | } |
| 44 | |
| 45 | public MMEUES1APID getDestination() { |
| 46 | return destination; |
| 47 | } |
| 48 | |
| 49 | public void setDestination(MMEUES1APID destination) { |
| 50 | this.destination = destination; |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public boolean equals(Object o) { |
| 55 | return this == o || |
| 56 | o != null && |
| 57 | o instanceof LinkId && |
| 58 | destination.equals(((LinkId) o).destination) && |
| 59 | source.equals(((LinkId) o).source); |
| 60 | |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public int hashCode() { |
| 65 | int result = source.hashCode(); |
| 66 | result = 31 * result + destination.hashCode(); |
| 67 | return result; |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public String toString() { |
| 72 | StringBuilder sb = new StringBuilder(); |
| 73 | sb.append("{\n") |
| 74 | .append(source != null ? "\"cell\":" + source : "") |
| 75 | .append(destination != null ? ",\n\"ue\":" + destination : "") |
| 76 | .append("\n}\n"); |
| 77 | return sb.toString(); |
| 78 | } |
| 79 | } |