2 * Copyright 2016 Huawei Technologies Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.onap.vfc.nfvo.resmanagement.service.entity;
19 import org.apache.commons.lang.StringUtils;
20 import org.onap.vfc.nfvo.resmanagement.common.util.JsonUtil;
22 import net.sf.json.JSONObject;
25 * Port Entity Class.<br/>
30 * @version NFVO 0.5 Aug 31, 2016
32 public class PortEntity {
38 private String networkId;
40 private String status;
42 private String tenantId;
46 private String vimName;
49 * @return Returns the id.
51 public String getId() {
56 * @param id The id to set.
58 public void setId(String id) {
59 this.id = id == null ? null : id.trim();
63 * @return Returns the name.
65 public String getName() {
70 * @param name The name to set.
72 public void setName(String name) {
77 * @return Returns the networkId.
79 public String getNetworkId() {
84 * @param networkId The networkId to set.
86 public void setNetworkId(String networkId) {
87 this.networkId = networkId;
91 * @return Returns the status.
93 public String getStatus() {
98 * @param status The status to set.
100 public void setStatus(String status) {
101 this.status = status;
105 * @return Returns the tenantId.
107 public String getTenantId() {
112 * @param tenantId The tenantId to set.
114 public void setTenantId(String tenantId) {
115 this.tenantId = tenantId;
119 * @return Returns the vimId.
121 public String getVimId() {
126 * @param vimId The vimId to set.
128 public void setVimId(String vimId) {
133 * @return Returns the vimName.
135 public String getVimName() {
140 * @param vimName The vimName to set.
142 public void setVimName(String vimName) {
143 this.vimName = vimName;
154 public static PortEntity toEntity(JSONObject jsonObject) {
155 PortEntity portEntity = new PortEntity();
156 portEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id"));
157 portEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name"));
158 portEntity.setNetworkId(JsonUtil.getJsonFieldStr(jsonObject, "networkId"));
159 portEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status"));
160 portEntity.setTenantId(JsonUtil.getJsonFieldStr(jsonObject, "tenantId"));
161 portEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId"));
162 portEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName"));
167 public String toString() {
168 JSONObject portResJson = new JSONObject();
169 portResJson.put("id", StringUtils.trimToEmpty(this.getId()));
170 portResJson.put("name", StringUtils.trimToEmpty(this.getName()));
171 portResJson.put("networkId", StringUtils.trimToEmpty(this.getNetworkId()));
172 portResJson.put("status", StringUtils.trimToEmpty(this.getStatus()));
173 portResJson.put("tenantId", StringUtils.trimToEmpty(this.getTenantId()));
174 portResJson.put("vimId", StringUtils.trimToEmpty(this.getVimId()));
175 portResJson.put("vimName", StringUtils.trimToEmpty(this.getVimName()));
176 return portResJson.toString();