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.openo.nfvo.resmanagement.service.entity;
19 import java.io.Serializable;
21 import org.apache.commons.lang3.StringUtils;
22 import org.openo.nfvo.resmanagement.common.util.JsonUtil;
24 import net.sf.json.JSONObject;
30 public class VmEntity implements Serializable {
36 private String vmName;
39 private String vmStatus;
42 private String vnfInstanceId;
44 private static final long serialVersionUID = 1L;
46 public String getVmId() {
50 public void setVmId(String vmId) {
54 public String getVmName() {
58 public void setVmName(String vmName) {
62 public String getVmStatus() {
66 public void setVmStatus(String vmStatus) {
67 this.vmStatus = vmStatus;
70 public String getVnfInstanceId() {
74 public void setVnfInstanceId(String vnfInstanceId) {
75 this.vnfInstanceId = vnfInstanceId;
78 public static VmEntity toEntity(JSONObject jsonObject) {
79 VmEntity vmEntity = new VmEntity();
80 vmEntity.setVmId(JsonUtil.getJsonFieldStr(jsonObject, "vmId"));
81 vmEntity.setVmName(JsonUtil.getJsonFieldStr(jsonObject, "vmName"));
82 vmEntity.setVmStatus(JsonUtil.getJsonFieldStr(jsonObject, "vmStatus"));
83 vmEntity.setVnfInstanceId(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceId"));
88 public String toString() {
89 JSONObject vmResJson = new JSONObject();
90 vmResJson.put("vmId", StringUtils.trimToEmpty(this.getVmId()));
91 vmResJson.put("vmName", StringUtils.trimToEmpty(this.getVmName()));
92 vmResJson.put("vmStatus", StringUtils.trimToEmpty(this.getVmStatus()));
93 vmResJson.put("vnfInstanceId", StringUtils.trimToEmpty(this.getVnfInstanceId()));
94 return vmResJson.toString();