slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1 | /* |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 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 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 19 | import com.fasterxml.jackson.annotation.JsonIgnore; |
| 20 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 21 | import com.fasterxml.jackson.annotation.JsonProperty; |
| 22 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 23 | import org.onosproject.xran.codecs.api.ECGI; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 24 | import org.onosproject.xran.entities.RnibCell; |
| 25 | import org.onosproject.xran.entities.RnibUe; |
| 26 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 27 | /** |
| 28 | * Class for LinkId. |
| 29 | */ |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 30 | @JsonPropertyOrder({ |
| 31 | "ECGI", |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 32 | "UEID" |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 33 | }) |
| 34 | @JsonIgnoreProperties(ignoreUnknown = true) |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 35 | public final class LinkId { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 36 | @JsonIgnore |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 37 | private RnibCell cell; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 38 | @JsonIgnore |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 39 | private RnibUe ue; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 40 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 41 | private LinkId(RnibCell cell, RnibUe ue) { |
| 42 | this.cell = cell; |
| 43 | this.ue = ue; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 44 | } |
| 45 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 46 | /** |
| 47 | * Create new LinkId. |
| 48 | * @param cell Cell |
| 49 | * @param ue UE |
| 50 | * @return new LinkId |
| 51 | */ |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 52 | public static LinkId valueOf(RnibCell cell, RnibUe ue) { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 53 | return new LinkId(cell, ue); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 54 | } |
| 55 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 56 | /** |
| 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) { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 63 | RnibCell cell = new RnibCell(); |
| 64 | RnibUe ue = new RnibUe(); |
| 65 | |
| 66 | cell.setEcgi(ecgi); |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 67 | ue.setId(ueId); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 68 | return new LinkId(cell, ue); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 69 | } |
| 70 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 71 | /** |
| 72 | * Get ECGI. |
| 73 | * @return ECGI |
| 74 | */ |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 75 | @JsonProperty("ECGI") |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 76 | public ECGI getEcgi() { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 77 | return cell.getEcgi(); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 78 | } |
| 79 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 80 | /** |
| 81 | * Set ECGI. |
| 82 | * @param sourceId ECGI |
| 83 | */ |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 84 | @JsonProperty("ECGI") |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 85 | public void setEcgi(ECGI sourceId) { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 86 | cell.setEcgi(sourceId); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 87 | } |
| 88 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 89 | /** |
| 90 | * Get UE ID. |
| 91 | * @return long UE ID |
| 92 | */ |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 93 | @JsonProperty("UEID") |
| 94 | public Long getUeId() { |
| 95 | return ue.getId(); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 96 | } |
| 97 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 98 | /** |
| 99 | * Set UE ID. |
| 100 | * @param destinationId long UE ID |
| 101 | */ |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 102 | @JsonProperty("UEID") |
| 103 | public void setUeId(Long destinationId) { |
| 104 | ue.setId(destinationId); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 105 | } |
| 106 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 107 | /** |
| 108 | * Get Cell. |
| 109 | * @return Cell |
| 110 | */ |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 111 | @JsonIgnore |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 112 | public RnibCell getCell() { |
| 113 | return cell; |
| 114 | } |
| 115 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 116 | /** |
| 117 | * Set Cell. |
| 118 | * @param cell Cell |
| 119 | */ |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 120 | @JsonIgnore |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 121 | public void setCell(RnibCell cell) { |
| 122 | this.cell = cell; |
| 123 | } |
| 124 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 125 | /** |
| 126 | * Get UE. |
| 127 | * @return UE |
| 128 | */ |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 129 | @JsonIgnore |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 130 | public RnibUe getUe() { |
| 131 | return ue; |
| 132 | } |
| 133 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 134 | /** |
| 135 | * Set UE. |
| 136 | * @param ue UE |
| 137 | */ |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 138 | @JsonIgnore |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 139 | public void setUe(RnibUe ue) { |
| 140 | this.ue = ue; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 141 | } |
| 142 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 143 | /* |
| 144 | * (non-Javadoc) |
| 145 | * |
| 146 | * @see java.lang.Object#equals() |
| 147 | */ |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 148 | @Override |
| 149 | public boolean equals(Object o) { |
| 150 | return this == o || |
| 151 | o != null && |
| 152 | o instanceof LinkId && |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 153 | cell.getEcgi().equals(((LinkId) o).cell.getEcgi()) && |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 154 | ue.getId().equals(((LinkId) o).ue.getId()); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 155 | |
| 156 | } |
| 157 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 158 | /* |
| 159 | * (non-Javadoc) |
| 160 | * |
| 161 | * @see java.lang.Object#hashCode() |
| 162 | */ |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 163 | @Override |
| 164 | public int hashCode() { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 165 | int result = cell.getEcgi().hashCode(); |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 166 | result = 31 * result + ue.getId().hashCode(); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 167 | return result; |
| 168 | } |
| 169 | |
| 170 | @Override |
| 171 | public String toString() { |
| 172 | StringBuilder sb = new StringBuilder(); |
| 173 | sb.append("{\n") |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 174 | .append(cell != null ? "\"cell\":" + cell : "") |
| 175 | .append(ue != null ? ",\n\"ue\":" + ue : "") |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 176 | .append("\n}\n"); |
| 177 | return sb.toString(); |
| 178 | } |
| 179 | } |