e01cabdaefb9a8e9f7e29b373f2d4e24646fd28c
[vfc/nfvo/resmanagement.git] /
1 /*
2  * Copyright 2016 Huawei Technologies Co., Ltd.
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.openo.nfvo.resmanagement.service.entity;
18
19 import java.io.Serializable;
20
21 import org.apache.commons.lang3.StringUtils;
22 import org.openo.nfvo.resmanagement.common.util.JsonUtil;
23
24 import net.sf.json.JSONObject;
25
26 /**
27  * @author l00345485
28  * @date 2016-10-28
29  */
30 public class VmEntity implements Serializable {
31
32     /**  */
33     private String vmId;
34
35     /**  */
36     private String vmName;
37
38     /**  */
39     private String vmStatus;
40
41     /**  */
42     private String vnfInstanceId;
43
44     private static final long serialVersionUID = 1L;
45
46     public String getVmId() {
47         return vmId;
48     }
49
50     public void setVmId(String vmId) {
51         this.vmId = vmId;
52     }
53
54     public String getVmName() {
55         return vmName;
56     }
57
58     public void setVmName(String vmName) {
59         this.vmName = vmName;
60     }
61
62     public String getVmStatus() {
63         return vmStatus;
64     }
65
66     public void setVmStatus(String vmStatus) {
67         this.vmStatus = vmStatus;
68     }
69
70     public String getVnfInstanceId() {
71         return vnfInstanceId;
72     }
73
74     public void setVnfInstanceId(String vnfInstanceId) {
75         this.vnfInstanceId = vnfInstanceId;
76     }
77
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"));
84         return vmEntity;
85     }
86
87     @Override
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();
95     }
96 }