blob: e2b489aa752aa55c26399bf6cc349835ceacbd28 [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;
slowr13fa5b02017-08-08 16:32:31 -070024import org.onosproject.xran.entities.RnibCell;
25import org.onosproject.xran.entities.RnibUe;
26
slowr60d4d102017-08-16 18:33:58 -070027@JsonPropertyOrder({
28 "ECGI",
slowrc86750e2017-08-22 17:26:47 -070029 "UEID"
slowr60d4d102017-08-16 18:33:58 -070030})
31@JsonIgnoreProperties(ignoreUnknown = true)
slowr13fa5b02017-08-08 16:32:31 -070032public class LinkId {
slowr60d4d102017-08-16 18:33:58 -070033 @JsonIgnore
slowr67d05e42017-08-11 20:37:22 -070034 private RnibCell cell;
slowr60d4d102017-08-16 18:33:58 -070035 @JsonIgnore
slowr67d05e42017-08-11 20:37:22 -070036 private RnibUe ue;
slowr13fa5b02017-08-08 16:32:31 -070037
slowr67d05e42017-08-11 20:37:22 -070038 private LinkId(RnibCell cell, RnibUe ue) {
39 this.cell = cell;
40 this.ue = ue;
slowr13fa5b02017-08-08 16:32:31 -070041 }
42
43 public static LinkId valueOf(RnibCell cell, RnibUe ue) {
slowr67d05e42017-08-11 20:37:22 -070044 return new LinkId(cell, ue);
slowr13fa5b02017-08-08 16:32:31 -070045 }
46
slowrc86750e2017-08-22 17:26:47 -070047 public static LinkId valueOf(ECGI ecgi, Long UeId) {
slowr67d05e42017-08-11 20:37:22 -070048 RnibCell cell = new RnibCell();
49 RnibUe ue = new RnibUe();
50
51 cell.setEcgi(ecgi);
slowrc86750e2017-08-22 17:26:47 -070052 ue.setId(UeId);
slowr67d05e42017-08-11 20:37:22 -070053 return new LinkId(cell, ue);
slowr13fa5b02017-08-08 16:32:31 -070054 }
55
slowr60d4d102017-08-16 18:33:58 -070056 @JsonProperty("ECGI")
slowr8ddc2b12017-08-14 14:13:38 -070057 public ECGI getEcgi() {
slowr67d05e42017-08-11 20:37:22 -070058 return cell.getEcgi();
slowr13fa5b02017-08-08 16:32:31 -070059 }
60
slowr60d4d102017-08-16 18:33:58 -070061 @JsonProperty("ECGI")
slowr8ddc2b12017-08-14 14:13:38 -070062 public void setEcgi(ECGI sourceId) {
slowr67d05e42017-08-11 20:37:22 -070063 cell.setEcgi(sourceId);
slowr13fa5b02017-08-08 16:32:31 -070064 }
65
slowrc86750e2017-08-22 17:26:47 -070066 @JsonProperty("UEID")
67 public Long getUeId() {
68 return ue.getId();
slowr67d05e42017-08-11 20:37:22 -070069 }
70
slowrc86750e2017-08-22 17:26:47 -070071 @JsonProperty("UEID")
72 public void setUeId(Long destinationId) {
73 ue.setId(destinationId);
slowr67d05e42017-08-11 20:37:22 -070074 }
75
slowr60d4d102017-08-16 18:33:58 -070076 @JsonIgnore
slowr67d05e42017-08-11 20:37:22 -070077 public RnibCell getCell() {
78 return cell;
79 }
80
slowr60d4d102017-08-16 18:33:58 -070081 @JsonIgnore
slowr67d05e42017-08-11 20:37:22 -070082 public void setCell(RnibCell cell) {
83 this.cell = cell;
84 }
85
slowr60d4d102017-08-16 18:33:58 -070086 @JsonIgnore
slowr67d05e42017-08-11 20:37:22 -070087 public RnibUe getUe() {
88 return ue;
89 }
90
slowr60d4d102017-08-16 18:33:58 -070091 @JsonIgnore
slowr67d05e42017-08-11 20:37:22 -070092 public void setUe(RnibUe ue) {
93 this.ue = ue;
slowr13fa5b02017-08-08 16:32:31 -070094 }
95
96 @Override
97 public boolean equals(Object o) {
98 return this == o ||
99 o != null &&
100 o instanceof LinkId &&
slowr67d05e42017-08-11 20:37:22 -0700101 cell.getEcgi().equals(((LinkId) o).cell.getEcgi()) &&
slowrc86750e2017-08-22 17:26:47 -0700102 ue.getId().equals(((LinkId) o).ue.getId());
slowr13fa5b02017-08-08 16:32:31 -0700103
104 }
105
106 @Override
107 public int hashCode() {
slowr67d05e42017-08-11 20:37:22 -0700108 int result = cell.getEcgi().hashCode();
slowrc86750e2017-08-22 17:26:47 -0700109 result = 31 * result + ue.getId().hashCode();
slowr13fa5b02017-08-08 16:32:31 -0700110 return result;
111 }
112
113 @Override
114 public String toString() {
115 StringBuilder sb = new StringBuilder();
116 sb.append("{\n")
slowr67d05e42017-08-11 20:37:22 -0700117 .append(cell != null ? "\"cell\":" + cell : "")
118 .append(ue != null ? ",\n\"ue\":" + ue : "")
slowr13fa5b02017-08-08 16:32:31 -0700119 .append("\n}\n");
120 return sb.toString();
121 }
122}