Update gvnfm-driver .gitreview file
[vfc/nfvo/driver/vnfm/gvnfm.git] / juju / juju-vnfmadapter / Juju-vnfmadapterService / service / src / main / java / org / onap / vfc / nfvo / vnfm / gvnfm / jujuvnfmadapter / service / entity / JujuDriver.java
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.vnfm.gvnfm.jujuvnfmadapter.service.entity;
18
19 import java.util.List;
20
21 import net.sf.json.JSONObject;
22
23 import org.apache.commons.lang3.builder.ToStringBuilder;
24 import org.apache.commons.lang3.builder.ToStringStyle;
25
26 /**
27  * 
28  * Juju Driver Class.<br>
29  * <p>
30  * </p>
31  * 
32  * @author
33  * @version     NFVO 0.5  Sep 10, 2016
34  */
35 public class JujuDriver {
36
37     private String serviceName;
38
39     private String protocol;
40
41     private String version;
42
43     private String visualRange;
44
45     private String url;
46
47     private List nodes;
48
49     private String ip;
50
51     private String port;
52
53     private String ttl;
54
55     private String status;
56
57     public static final String NOTES = "notes";
58        
59     public JujuDriver() {
60        // Default Constructor
61     }
62     
63     /**
64      * 
65      * Constructor<br>
66      * <p>
67      * </p>
68      * 
69      * @param jujuJsonObject
70      * @since  NFVO 0.5
71      */
72     public JujuDriver(JSONObject jujuJsonObject) {
73         this.serviceName = jujuJsonObject.getString("serviceName");
74         this.protocol = jujuJsonObject.getString("protocol");
75         this.version = jujuJsonObject.getString("version");
76         this.visualRange = jujuJsonObject.getString("visualRange");
77         this.url = jujuJsonObject.getString("url");
78         this.nodes = jujuJsonObject.getJSONArray("nodes");
79         this.ip = jujuJsonObject.getJSONArray(NOTES).getString(0);
80         this.port = jujuJsonObject.getJSONArray(NOTES).getString(1);
81         this.ttl = jujuJsonObject.getJSONArray(NOTES).getString(2);
82         this.status = jujuJsonObject.getString("status");
83     }
84     
85     public String getServiceName() {
86         return serviceName;
87     }
88
89     public void setServiceName(String serviceName) {
90         this.serviceName = serviceName;
91     }
92
93     public String getVisualRange() {
94         return visualRange;
95     }
96
97     public void setVisualRange(String visualRange) {
98         this.visualRange = visualRange;
99     }
100
101     public String getProtocol() {
102         return protocol;
103     }
104
105     public void setProtocol(String protocol) {
106         this.protocol = protocol;
107     }
108
109     public String getVersion() {
110         return version;
111     }
112
113     public void setVersion(String version) {
114         this.version = version;
115     }
116
117     public List getNodes() {
118         return nodes;
119     }
120
121     public void setNodes(List nodes) {
122         this.nodes = nodes;
123     }
124
125     public String getUrl() {
126         return url;
127     }
128
129     public void setUrl(String url) {
130         this.url = url;
131     }
132
133     public String getIP() {
134         return ip;
135     }
136
137     public void setIP(String ip) {
138         this.ip = ip;
139     }
140
141     public String getPort() {
142         return port;
143     }
144
145     public void setPort(String port) {
146         this.port = port;
147     }
148
149     public String getTtl() {
150         return ttl;
151     }
152
153     public void setTtl(String ttl) {
154         this.ttl = ttl;
155     }
156
157     public String getStatus() {
158         return status;
159     }
160
161     public void setStatus(String status) {
162         this.status = status;
163     }
164
165     @Override
166     public String toString() {
167         return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
168     }
169
170     @Override
171     public int hashCode() {
172         final int prime = 31;
173         int result = 1;
174         result = prime * result + ((serviceName == null) ? 0 : serviceName.hashCode());
175         return result;
176     }
177
178     @Override
179     public boolean equals(Object obj) {
180         if(this == obj) {
181             return true;
182         }
183         if(obj == null) {
184             return false;
185         }
186         if(!(obj instanceof JujuDriver)) {
187             return false;
188         }
189         if(getClass() != obj.getClass()) {
190             return false;
191         }
192         JujuDriver other = (JujuDriver)obj;
193         if(serviceName == null) {
194             if(other.serviceName != null) {
195                 return false;
196             }
197         } else if(!serviceName.equals(other.serviceName)) {
198             return false;
199         }
200         return true;
201     }
202
203 }