slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 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 | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 27 | @JsonPropertyOrder({ |
| 28 | "ECGI", |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame^] | 29 | "UEID" |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 30 | }) |
| 31 | @JsonIgnoreProperties(ignoreUnknown = true) |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 32 | public class LinkId { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 33 | @JsonIgnore |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 34 | private RnibCell cell; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 35 | @JsonIgnore |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 36 | private RnibUe ue; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 37 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 38 | private LinkId(RnibCell cell, RnibUe ue) { |
| 39 | this.cell = cell; |
| 40 | this.ue = ue; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | public static LinkId valueOf(RnibCell cell, RnibUe ue) { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 44 | return new LinkId(cell, ue); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 45 | } |
| 46 | |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame^] | 47 | public static LinkId valueOf(ECGI ecgi, Long UeId) { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 48 | RnibCell cell = new RnibCell(); |
| 49 | RnibUe ue = new RnibUe(); |
| 50 | |
| 51 | cell.setEcgi(ecgi); |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame^] | 52 | ue.setId(UeId); |
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 | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 56 | @JsonProperty("ECGI") |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 57 | public ECGI getEcgi() { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 58 | return cell.getEcgi(); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 59 | } |
| 60 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 61 | @JsonProperty("ECGI") |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 62 | public void setEcgi(ECGI sourceId) { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 63 | cell.setEcgi(sourceId); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 64 | } |
| 65 | |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame^] | 66 | @JsonProperty("UEID") |
| 67 | public Long getUeId() { |
| 68 | return ue.getId(); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 69 | } |
| 70 | |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame^] | 71 | @JsonProperty("UEID") |
| 72 | public void setUeId(Long destinationId) { |
| 73 | ue.setId(destinationId); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 74 | } |
| 75 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 76 | @JsonIgnore |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 77 | public RnibCell getCell() { |
| 78 | return cell; |
| 79 | } |
| 80 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 81 | @JsonIgnore |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 82 | public void setCell(RnibCell cell) { |
| 83 | this.cell = cell; |
| 84 | } |
| 85 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 86 | @JsonIgnore |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 87 | public RnibUe getUe() { |
| 88 | return ue; |
| 89 | } |
| 90 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 91 | @JsonIgnore |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 92 | public void setUe(RnibUe ue) { |
| 93 | this.ue = ue; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | @Override |
| 97 | public boolean equals(Object o) { |
| 98 | return this == o || |
| 99 | o != null && |
| 100 | o instanceof LinkId && |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 101 | cell.getEcgi().equals(((LinkId) o).cell.getEcgi()) && |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame^] | 102 | ue.getId().equals(((LinkId) o).ue.getId()); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 103 | |
| 104 | } |
| 105 | |
| 106 | @Override |
| 107 | public int hashCode() { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 108 | int result = cell.getEcgi().hashCode(); |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame^] | 109 | result = 31 * result + ue.getId().hashCode(); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 110 | return result; |
| 111 | } |
| 112 | |
| 113 | @Override |
| 114 | public String toString() { |
| 115 | StringBuilder sb = new StringBuilder(); |
| 116 | sb.append("{\n") |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 117 | .append(cell != null ? "\"cell\":" + cell : "") |
| 118 | .append(ue != null ? ",\n\"ue\":" + ue : "") |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 119 | .append("\n}\n"); |
| 120 | return sb.toString(); |
| 121 | } |
| 122 | } |