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 { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 25 | private RnibCell cell; |
| 26 | private RnibUe ue; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 27 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 28 | private LinkId(RnibCell cell, RnibUe ue) { |
| 29 | this.cell = cell; |
| 30 | this.ue = ue; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | public static LinkId valueOf(RnibCell cell, RnibUe ue) { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 34 | return new LinkId(cell, ue); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 35 | } |
| 36 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 37 | public static LinkId valueOf(ECGI ecgi, MMEUES1APID mmeues1APID) { |
| 38 | RnibCell cell = new RnibCell(); |
| 39 | RnibUe ue = new RnibUe(); |
| 40 | |
| 41 | cell.setEcgi(ecgi); |
| 42 | ue.setMmeS1apId(mmeues1APID); |
| 43 | return new LinkId(cell, ue); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 44 | } |
| 45 | |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame^] | 46 | public ECGI getEcgi() { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 47 | return cell.getEcgi(); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 48 | } |
| 49 | |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame^] | 50 | public void setEcgi(ECGI sourceId) { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 51 | cell.setEcgi(sourceId); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 52 | } |
| 53 | |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame^] | 54 | public MMEUES1APID getMmeues1apid() { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 55 | return ue.getMmeS1apId(); |
| 56 | } |
| 57 | |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame^] | 58 | public void setMmeues1apid(MMEUES1APID destinationId) { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 59 | ue.setMmeS1apId(destinationId); |
| 60 | } |
| 61 | |
| 62 | public RnibCell getCell() { |
| 63 | return cell; |
| 64 | } |
| 65 | |
| 66 | public void setCell(RnibCell cell) { |
| 67 | this.cell = cell; |
| 68 | } |
| 69 | |
| 70 | public RnibUe getUe() { |
| 71 | return ue; |
| 72 | } |
| 73 | |
| 74 | public void setUe(RnibUe ue) { |
| 75 | this.ue = ue; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | @Override |
| 79 | public boolean equals(Object o) { |
| 80 | return this == o || |
| 81 | o != null && |
| 82 | o instanceof LinkId && |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 83 | cell.getEcgi().equals(((LinkId) o).cell.getEcgi()) && |
| 84 | ue.getMmeS1apId().equals(((LinkId) o).ue.getMmeS1apId()); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 85 | |
| 86 | } |
| 87 | |
| 88 | @Override |
| 89 | public int hashCode() { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 90 | int result = cell.getEcgi().hashCode(); |
| 91 | result = 31 * result + ue.getMmeS1apId().hashCode(); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 92 | return result; |
| 93 | } |
| 94 | |
| 95 | @Override |
| 96 | public String toString() { |
| 97 | StringBuilder sb = new StringBuilder(); |
| 98 | sb.append("{\n") |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 99 | .append(cell != null ? "\"cell\":" + cell : "") |
| 100 | .append(ue != null ? ",\n\"ue\":" + ue : "") |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 101 | .append("\n}\n"); |
| 102 | return sb.toString(); |
| 103 | } |
| 104 | } |