blob: 8b7dabb1ba9e2bc5c0f3c58921ff3123b8e66f23 [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
slowr60d4d102017-08-16 18:33:58 -070019import com.fasterxml.jackson.annotation.JsonIgnore;
20import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
21import com.fasterxml.jackson.annotation.JsonProperty;
22import com.fasterxml.jackson.annotation.JsonPropertyOrder;
slowr13fa5b02017-08-08 16:32:31 -070023import org.onosproject.xran.codecs.api.ECGI;
24import org.onosproject.xran.codecs.api.MMEUES1APID;
25import org.onosproject.xran.entities.RnibCell;
26import org.onosproject.xran.entities.RnibUe;
27
slowr60d4d102017-08-16 18:33:58 -070028@JsonPropertyOrder({
29 "ECGI",
30 "MMEUES1APID"
31})
32@JsonIgnoreProperties(ignoreUnknown = true)
slowr13fa5b02017-08-08 16:32:31 -070033public class LinkId {
slowr60d4d102017-08-16 18:33:58 -070034 @JsonIgnore
slowr67d05e42017-08-11 20:37:22 -070035 private RnibCell cell;
slowr60d4d102017-08-16 18:33:58 -070036 @JsonIgnore
slowr67d05e42017-08-11 20:37:22 -070037 private RnibUe ue;
slowr13fa5b02017-08-08 16:32:31 -070038
slowr67d05e42017-08-11 20:37:22 -070039 private LinkId(RnibCell cell, RnibUe ue) {
40 this.cell = cell;
41 this.ue = ue;
slowr13fa5b02017-08-08 16:32:31 -070042 }
43
44 public static LinkId valueOf(RnibCell cell, RnibUe ue) {
slowr67d05e42017-08-11 20:37:22 -070045 return new LinkId(cell, ue);
slowr13fa5b02017-08-08 16:32:31 -070046 }
47
slowr67d05e42017-08-11 20:37:22 -070048 public static LinkId valueOf(ECGI ecgi, MMEUES1APID mmeues1APID) {
49 RnibCell cell = new RnibCell();
50 RnibUe ue = new RnibUe();
51
52 cell.setEcgi(ecgi);
53 ue.setMmeS1apId(mmeues1APID);
54 return new LinkId(cell, ue);
slowr13fa5b02017-08-08 16:32:31 -070055 }
56
slowr60d4d102017-08-16 18:33:58 -070057 @JsonProperty("ECGI")
slowr8ddc2b12017-08-14 14:13:38 -070058 public ECGI getEcgi() {
slowr67d05e42017-08-11 20:37:22 -070059 return cell.getEcgi();
slowr13fa5b02017-08-08 16:32:31 -070060 }
61
slowr60d4d102017-08-16 18:33:58 -070062 @JsonProperty("ECGI")
slowr8ddc2b12017-08-14 14:13:38 -070063 public void setEcgi(ECGI sourceId) {
slowr67d05e42017-08-11 20:37:22 -070064 cell.setEcgi(sourceId);
slowr13fa5b02017-08-08 16:32:31 -070065 }
66
slowr60d4d102017-08-16 18:33:58 -070067 @JsonProperty("MMEUES1APID")
slowr8ddc2b12017-08-14 14:13:38 -070068 public MMEUES1APID getMmeues1apid() {
slowr67d05e42017-08-11 20:37:22 -070069 return ue.getMmeS1apId();
70 }
71
slowr60d4d102017-08-16 18:33:58 -070072 @JsonProperty("MMEUES1APID")
slowr8ddc2b12017-08-14 14:13:38 -070073 public void setMmeues1apid(MMEUES1APID destinationId) {
slowr67d05e42017-08-11 20:37:22 -070074 ue.setMmeS1apId(destinationId);
75 }
76
slowr60d4d102017-08-16 18:33:58 -070077 @JsonIgnore
slowr67d05e42017-08-11 20:37:22 -070078 public RnibCell getCell() {
79 return cell;
80 }
81
slowr60d4d102017-08-16 18:33:58 -070082 @JsonIgnore
slowr67d05e42017-08-11 20:37:22 -070083 public void setCell(RnibCell cell) {
84 this.cell = cell;
85 }
86
slowr60d4d102017-08-16 18:33:58 -070087 @JsonIgnore
slowr67d05e42017-08-11 20:37:22 -070088 public RnibUe getUe() {
89 return ue;
90 }
91
slowr60d4d102017-08-16 18:33:58 -070092 @JsonIgnore
slowr67d05e42017-08-11 20:37:22 -070093 public void setUe(RnibUe ue) {
94 this.ue = ue;
slowr13fa5b02017-08-08 16:32:31 -070095 }
96
97 @Override
98 public boolean equals(Object o) {
99 return this == o ||
100 o != null &&
101 o instanceof LinkId &&
slowr67d05e42017-08-11 20:37:22 -0700102 cell.getEcgi().equals(((LinkId) o).cell.getEcgi()) &&
103 ue.getMmeS1apId().equals(((LinkId) o).ue.getMmeS1apId());
slowr13fa5b02017-08-08 16:32:31 -0700104
105 }
106
107 @Override
108 public int hashCode() {
slowr67d05e42017-08-11 20:37:22 -0700109 int result = cell.getEcgi().hashCode();
110 result = 31 * result + ue.getMmeS1apId().hashCode();
slowr13fa5b02017-08-08 16:32:31 -0700111 return result;
112 }
113
114 @Override
115 public String toString() {
116 StringBuilder sb = new StringBuilder();
117 sb.append("{\n")
slowr67d05e42017-08-11 20:37:22 -0700118 .append(cell != null ? "\"cell\":" + cell : "")
119 .append(ue != null ? ",\n\"ue\":" + ue : "")
slowr13fa5b02017-08-08 16:32:31 -0700120 .append("\n}\n");
121 return sb.toString();
122 }
123}