blob: a439461ed0f2a56582181979eed9c21e6cc38572 [file] [log] [blame]
slowr13fa5b02017-08-08 16:32:31 -07001/*
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08002 * Copyright 2017-present Open Networking Foundation
slowr13fa5b02017-08-08 16:32:31 -07003 *
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
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080017package org.onosproject.xran.impl.identifiers;
slowr13fa5b02017-08-08 16:32:31 -070018
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;
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080023import org.onosproject.xran.asn1lib.api.ECGI;
24import org.onosproject.xran.impl.entities.RnibCell;
25import org.onosproject.xran.impl.entities.RnibUe;
slowr13fa5b02017-08-08 16:32:31 -070026
slowr577f3222017-08-28 10:49:08 -070027/**
28 * Class for LinkId.
29 */
slowr60d4d102017-08-16 18:33:58 -070030@JsonPropertyOrder({
31 "ECGI",
slowrc86750e2017-08-22 17:26:47 -070032 "UEID"
slowr60d4d102017-08-16 18:33:58 -070033})
34@JsonIgnoreProperties(ignoreUnknown = true)
slowr577f3222017-08-28 10:49:08 -070035public final class LinkId {
slowr60d4d102017-08-16 18:33:58 -070036 @JsonIgnore
slowr67d05e42017-08-11 20:37:22 -070037 private RnibCell cell;
slowr60d4d102017-08-16 18:33:58 -070038 @JsonIgnore
slowr67d05e42017-08-11 20:37:22 -070039 private RnibUe ue;
slowr13fa5b02017-08-08 16:32:31 -070040
slowr67d05e42017-08-11 20:37:22 -070041 private LinkId(RnibCell cell, RnibUe ue) {
42 this.cell = cell;
43 this.ue = ue;
slowr13fa5b02017-08-08 16:32:31 -070044 }
45
slowr577f3222017-08-28 10:49:08 -070046 /**
47 * Create new LinkId.
48 * @param cell Cell
49 * @param ue UE
50 * @return new LinkId
51 */
slowr13fa5b02017-08-08 16:32:31 -070052 public static LinkId valueOf(RnibCell cell, RnibUe ue) {
slowr67d05e42017-08-11 20:37:22 -070053 return new LinkId(cell, ue);
slowr13fa5b02017-08-08 16:32:31 -070054 }
55
slowr577f3222017-08-28 10:49:08 -070056 /**
57 * Create new LinkID with ECGI and UE ID given.
58 * @param ecgi ECGI of new cell
59 * @param ueId UE ID of new UE
60 * @return LinkId
61 */
62 public static LinkId valueOf(ECGI ecgi, Long ueId) {
slowr67d05e42017-08-11 20:37:22 -070063 RnibCell cell = new RnibCell();
64 RnibUe ue = new RnibUe();
65
66 cell.setEcgi(ecgi);
slowr577f3222017-08-28 10:49:08 -070067 ue.setId(ueId);
slowr67d05e42017-08-11 20:37:22 -070068 return new LinkId(cell, ue);
slowr13fa5b02017-08-08 16:32:31 -070069 }
70
slowr577f3222017-08-28 10:49:08 -070071 /**
72 * Get ECGI.
73 * @return ECGI
74 */
slowr60d4d102017-08-16 18:33:58 -070075 @JsonProperty("ECGI")
slowr8ddc2b12017-08-14 14:13:38 -070076 public ECGI getEcgi() {
slowr67d05e42017-08-11 20:37:22 -070077 return cell.getEcgi();
slowr13fa5b02017-08-08 16:32:31 -070078 }
79
slowr577f3222017-08-28 10:49:08 -070080 /**
81 * Set ECGI.
82 * @param sourceId ECGI
83 */
slowr60d4d102017-08-16 18:33:58 -070084 @JsonProperty("ECGI")
slowr8ddc2b12017-08-14 14:13:38 -070085 public void setEcgi(ECGI sourceId) {
slowr67d05e42017-08-11 20:37:22 -070086 cell.setEcgi(sourceId);
slowr13fa5b02017-08-08 16:32:31 -070087 }
88
slowr577f3222017-08-28 10:49:08 -070089 /**
90 * Get UE ID.
91 * @return long UE ID
92 */
slowrc86750e2017-08-22 17:26:47 -070093 @JsonProperty("UEID")
94 public Long getUeId() {
95 return ue.getId();
slowr67d05e42017-08-11 20:37:22 -070096 }
97
slowr577f3222017-08-28 10:49:08 -070098 /**
99 * Set UE ID.
100 * @param destinationId long UE ID
101 */
slowrc86750e2017-08-22 17:26:47 -0700102 @JsonProperty("UEID")
103 public void setUeId(Long destinationId) {
104 ue.setId(destinationId);
slowr67d05e42017-08-11 20:37:22 -0700105 }
106
slowr577f3222017-08-28 10:49:08 -0700107 /**
108 * Get Cell.
109 * @return Cell
110 */
slowr60d4d102017-08-16 18:33:58 -0700111 @JsonIgnore
slowr67d05e42017-08-11 20:37:22 -0700112 public RnibCell getCell() {
113 return cell;
114 }
115
slowr577f3222017-08-28 10:49:08 -0700116 /**
117 * Set Cell.
118 * @param cell Cell
119 */
slowr60d4d102017-08-16 18:33:58 -0700120 @JsonIgnore
slowr67d05e42017-08-11 20:37:22 -0700121 public void setCell(RnibCell cell) {
122 this.cell = cell;
123 }
124
slowr577f3222017-08-28 10:49:08 -0700125 /**
126 * Get UE.
127 * @return UE
128 */
slowr60d4d102017-08-16 18:33:58 -0700129 @JsonIgnore
slowr67d05e42017-08-11 20:37:22 -0700130 public RnibUe getUe() {
131 return ue;
132 }
133
slowr577f3222017-08-28 10:49:08 -0700134 /**
135 * Set UE.
136 * @param ue UE
137 */
slowr60d4d102017-08-16 18:33:58 -0700138 @JsonIgnore
slowr67d05e42017-08-11 20:37:22 -0700139 public void setUe(RnibUe ue) {
140 this.ue = ue;
slowr13fa5b02017-08-08 16:32:31 -0700141 }
142
slowr577f3222017-08-28 10:49:08 -0700143 /*
144 * (non-Javadoc)
145 *
146 * @see java.lang.Object#equals()
147 */
slowr13fa5b02017-08-08 16:32:31 -0700148 @Override
149 public boolean equals(Object o) {
150 return this == o ||
151 o != null &&
152 o instanceof LinkId &&
slowr67d05e42017-08-11 20:37:22 -0700153 cell.getEcgi().equals(((LinkId) o).cell.getEcgi()) &&
slowrc86750e2017-08-22 17:26:47 -0700154 ue.getId().equals(((LinkId) o).ue.getId());
slowr13fa5b02017-08-08 16:32:31 -0700155
156 }
157
slowr577f3222017-08-28 10:49:08 -0700158 /*
159 * (non-Javadoc)
160 *
161 * @see java.lang.Object#hashCode()
162 */
slowr13fa5b02017-08-08 16:32:31 -0700163 @Override
164 public int hashCode() {
slowr67d05e42017-08-11 20:37:22 -0700165 int result = cell.getEcgi().hashCode();
slowrc86750e2017-08-22 17:26:47 -0700166 result = 31 * result + ue.getId().hashCode();
slowr13fa5b02017-08-08 16:32:31 -0700167 return result;
168 }
169
170 @Override
171 public String toString() {
172 StringBuilder sb = new StringBuilder();
173 sb.append("{\n")
slowr67d05e42017-08-11 20:37:22 -0700174 .append(cell != null ? "\"cell\":" + cell : "")
175 .append(ue != null ? ",\n\"ue\":" + ue : "")
slowr13fa5b02017-08-08 16:32:31 -0700176 .append("\n}\n");
177 return sb.toString();
178 }
179}