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