47005542d79eaff2a9815f97900f33741b5b1b8b
[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  * Port Entity Class.<br/>
26  * <p>
27  * </p>
28  *
29  * @author
30  * @version NFVO 0.5 Aug 31, 2016
31  */
32 public class PortEntity {
33
34     private String id;
35
36     private String name;
37
38     private String networkId;
39
40     private String status;
41
42     private String tenantId;
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 == null ? null : id.trim();
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 networkId.
78      */
79     public String getNetworkId() {
80         return networkId;
81     }
82
83     /**
84      * @param networkId The networkId to set.
85      */
86     public void setNetworkId(String networkId) {
87         this.networkId = networkId;
88     }
89
90     /**
91      * @return Returns the status.
92      */
93     public String getStatus() {
94         return status;
95     }
96
97     /**
98      * @param status The status to set.
99      */
100     public void setStatus(String status) {
101         this.status = status;
102     }
103
104     /**
105      * @return Returns the tenantId.
106      */
107     public String getTenantId() {
108         return tenantId;
109     }
110
111     /**
112      * @param tenantId The tenantId to set.
113      */
114     public void setTenantId(String tenantId) {
115         this.tenantId = tenantId;
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 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"));
163         return portEntity;
164     }
165
166     @Override
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();
177     }
178
179 }