f8166dafcedfea5dc36ede187163533c86b5874d
[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 org.apache.commons.lang3.StringUtils;
20 import org.openo.nfvo.resmanagement.common.util.JsonUtil;
21
22 import net.sf.json.JSONObject;
23
24 /**
25  * Host entity class.<br/>
26  * <p>
27  * </p>
28  *
29  * @author
30  * @version NFVO 0.5 Aug 31, 2016
31  */
32 public class HostEntity {
33
34     private String id;
35
36     private String name;
37
38     private String cpu;
39
40     private String memory;
41
42     private String disk;
43
44     private String vimId;
45
46     private String vimName;
47
48     /**
49      * @return Returns the id.
50      */
51     public String getId() {
52         return id;
53     }
54
55     /**
56      * @param id The id to set.
57      */
58     public void setId(String id) {
59         this.id = id;
60     }
61
62     /**
63      * @return Returns the name.
64      */
65     public String getName() {
66         return name;
67     }
68
69     /**
70      * @param name The name to set.
71      */
72     public void setName(String name) {
73         this.name = name;
74     }
75
76     /**
77      * @return Returns the cpu.
78      */
79     public String getCpu() {
80         return cpu;
81     }
82
83     /**
84      * @param cpu The cpu to set.
85      */
86     public void setCpu(String cpu) {
87         this.cpu = cpu;
88     }
89
90     /**
91      * @return Returns the memory.
92      */
93     public String getMemory() {
94         return memory;
95     }
96
97     /**
98      * @param memory The memory to set.
99      */
100     public void setMemory(String memory) {
101         this.memory = memory;
102     }
103
104     /**
105      * @return Returns the disk.
106      */
107     public String getDisk() {
108         return disk;
109     }
110
111     /**
112      * @param disk The disk to set.
113      */
114     public void setDisk(String disk) {
115         this.disk = disk;
116     }
117
118     /**
119      * @return Returns the vimId.
120      */
121     public String getVimId() {
122         return vimId;
123     }
124
125     /**
126      * @param vimId The vimId to set.
127      */
128     public void setVimId(String vimId) {
129         this.vimId = vimId;
130     }
131
132     /**
133      * @return Returns the vimName.
134      */
135     public String getVimName() {
136         return vimName;
137     }
138
139     /**
140      * @param vimName The vimName to set.
141      */
142     public void setVimName(String vimName) {
143         this.vimName = vimName;
144     }
145
146     /**
147      *
148      * To entity.<br>
149      *
150      * @param jsonObject
151      * @return
152      * @since  NFVO 0.5
153      */
154     public static HostEntity toEntity(JSONObject jsonObject) {
155         HostEntity hostEntity = new HostEntity();
156         hostEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id"));
157         hostEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name"));
158         hostEntity.setCpu(JsonUtil.getJsonFieldStr(jsonObject, "cpu"));
159         hostEntity.setMemory(JsonUtil.getJsonFieldStr(jsonObject, "memory"));
160         hostEntity.setDisk(JsonUtil.getJsonFieldStr(jsonObject, "disk"));
161         hostEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId"));
162         hostEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName"));
163         return hostEntity;
164     }
165
166     @Override
167     public String toString() {
168         JSONObject hostResJson = new JSONObject();
169         hostResJson.put("id", StringUtils.trimToEmpty(this.getId()));
170         hostResJson.put("name", StringUtils.trimToEmpty(this.getName()));
171         hostResJson.put("cpu", StringUtils.trimToEmpty(this.getCpu()));
172         hostResJson.put("memory", StringUtils.trimToEmpty(this.getMemory()));
173         hostResJson.put("disk", StringUtils.trimToEmpty(this.getDisk()));
174         hostResJson.put("vimId", StringUtils.trimToEmpty(this.getVimId()));
175         hostResJson.put("vimName", StringUtils.trimToEmpty(this.getVimName()));
176         return hostResJson.toString();
177     }
178
179 }