85bccc220ecafb1c59d4a817387dfd462e668c6a
[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.onap.vfc.nfvo.resmanagement.service.entity;
18
19 import org.apache.commons.lang.StringUtils;
20 import org.onap.vfc.nfvo.resmanagement.common.util.JsonUtil;
21
22 import net.sf.json.JSONObject;
23
24 /**
25  *
26  * Virtualised infrastructure manager entity class.<br>
27  * <p>
28  * </p>
29  *
30  * @author
31  * @version     NFVO 0.5  Sep 10, 2016
32  */
33 public class VimEntity {
34
35     /**
36      * This field corresponds to the database column vim.ID
37      *
38      * @mbggenerated
39      */
40     private String id;
41
42     /**
43      * This field corresponds to the database column vim.ID
44      *
45      * @mbggenerated
46      */
47     private String name;
48
49     /**
50      * This method was generated by MyBatis Generator. This method returns the
51      * value of the database column vim.ID
52      *
53      * @return the value of vim.ID
54      */
55     public String getId() {
56         return id;
57     }
58
59     /**
60      * This method was generated by MyBatis Generator. This method sets the
61      * value of the database column vim.ID
62      *
63      * @param id
64      * the value for vim.ID
65      */
66     public void setId(String id) {
67         this.id = id == null ? null : id.trim();
68     }
69
70     public String getName() {
71         return name;
72     }
73
74     public void setName(String name) {
75         this.name = name;
76     }
77
78     /**
79      *
80      * To Entity.<br>
81      *
82      * @param jsonObject
83      * @return
84      * @since  NFVO 0.5
85      */
86     public static VimEntity toEntity(JSONObject jsonObject) {
87         VimEntity vimEntity = new VimEntity();
88         vimEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id"));
89         vimEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name"));
90         return vimEntity;
91     }
92
93     /**
94      *
95      * To String.<br>
96      *
97      * @return
98      * @since   NFVO 0.5
99      */
100     public String toString() {
101         JSONObject resJson = new JSONObject();
102         resJson.put("id", StringUtils.trimToEmpty(this.getId()));
103         resJson.put("name", StringUtils.trimToEmpty(this.getName()));
104         return resJson.toString();
105     }
106 }