blob: b6fd611c7acea2d40c73ea1fcdbd8ab33c90eb13 [file] [log] [blame]
slowr13fa5b02017-08-08 16:32:31 -07001/*
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
17package org.onosproject.xran.identifiers;
18
19import org.onosproject.xran.codecs.api.ECGI;
20import org.onosproject.xran.codecs.api.MMEUES1APID;
21import org.onosproject.xran.entities.RnibCell;
22import org.onosproject.xran.entities.RnibUe;
23
24public class LinkId {
slowr67d05e42017-08-11 20:37:22 -070025 private RnibCell cell;
26 private RnibUe ue;
slowr13fa5b02017-08-08 16:32:31 -070027
slowr67d05e42017-08-11 20:37:22 -070028 private LinkId(RnibCell cell, RnibUe ue) {
29 this.cell = cell;
30 this.ue = ue;
slowr13fa5b02017-08-08 16:32:31 -070031 }
32
33 public static LinkId valueOf(RnibCell cell, RnibUe ue) {
slowr67d05e42017-08-11 20:37:22 -070034 return new LinkId(cell, ue);
slowr13fa5b02017-08-08 16:32:31 -070035 }
36
slowr67d05e42017-08-11 20:37:22 -070037 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);
slowr13fa5b02017-08-08 16:32:31 -070044 }
45
slowr8ddc2b12017-08-14 14:13:38 -070046 public ECGI getEcgi() {
slowr67d05e42017-08-11 20:37:22 -070047 return cell.getEcgi();
slowr13fa5b02017-08-08 16:32:31 -070048 }
49
slowr8ddc2b12017-08-14 14:13:38 -070050 public void setEcgi(ECGI sourceId) {
slowr67d05e42017-08-11 20:37:22 -070051 cell.setEcgi(sourceId);
slowr13fa5b02017-08-08 16:32:31 -070052 }
53
slowr8ddc2b12017-08-14 14:13:38 -070054 public MMEUES1APID getMmeues1apid() {
slowr67d05e42017-08-11 20:37:22 -070055 return ue.getMmeS1apId();
56 }
57
slowr8ddc2b12017-08-14 14:13:38 -070058 public void setMmeues1apid(MMEUES1APID destinationId) {
slowr67d05e42017-08-11 20:37:22 -070059 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;
slowr13fa5b02017-08-08 16:32:31 -070076 }
77
78 @Override
79 public boolean equals(Object o) {
80 return this == o ||
81 o != null &&
82 o instanceof LinkId &&
slowr67d05e42017-08-11 20:37:22 -070083 cell.getEcgi().equals(((LinkId) o).cell.getEcgi()) &&
84 ue.getMmeS1apId().equals(((LinkId) o).ue.getMmeS1apId());
slowr13fa5b02017-08-08 16:32:31 -070085
86 }
87
88 @Override
89 public int hashCode() {
slowr67d05e42017-08-11 20:37:22 -070090 int result = cell.getEcgi().hashCode();
91 result = 31 * result + ue.getMmeS1apId().hashCode();
slowr13fa5b02017-08-08 16:32:31 -070092 return result;
93 }
94
95 @Override
96 public String toString() {
97 StringBuilder sb = new StringBuilder();
98 sb.append("{\n")
slowr67d05e42017-08-11 20:37:22 -070099 .append(cell != null ? "\"cell\":" + cell : "")
100 .append(ue != null ? ",\n\"ue\":" + ue : "")
slowr13fa5b02017-08-08 16:32:31 -0700101 .append("\n}\n");
102 return sb.toString();
103 }
104}