fixing warnings from checkstyle in common-app-api
[sdc.git] / common-app-api / src / main / java / org / openecomp / sdc / common / api / HealthCheckInfo.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.common.api;
22
23 import com.google.gson.Gson;
24 import com.google.gson.reflect.TypeToken;
25
26 import java.lang.reflect.Type;
27 import java.util.List;
28
29 public class HealthCheckInfo {
30
31     private String healthCheckComponent;
32     private HealthCheckStatus healthCheckStatus;
33     private String version;
34     private String description;
35     private List<HealthCheckInfo> componentsInfo;
36
37     public HealthCheckInfo(String healthCheckComponent, HealthCheckStatus healthCheckStatus,
38                            String version, String description) {
39         super();
40         this.healthCheckComponent = healthCheckComponent;
41         this.healthCheckStatus = healthCheckStatus;
42         this.version = version;
43         this.description = description;
44     }
45
46     public HealthCheckInfo(String healthCheckComponent, HealthCheckStatus healthCheckStatus,
47                            String version, String description, List<HealthCheckInfo> componentsInfo) {
48         super();
49         this.healthCheckComponent = healthCheckComponent;
50         this.healthCheckStatus = healthCheckStatus;
51         this.version = version;
52         this.description = description;
53         this.componentsInfo = componentsInfo;
54     }
55
56     public HealthCheckInfo() {
57         super();
58     }
59
60     public String getHealthCheckComponent() {
61         return healthCheckComponent;
62     }
63
64     public HealthCheckStatus getHealthCheckStatus() {
65         return healthCheckStatus;
66     }
67
68     public void setHealthCheckStatus(HealthCheckStatus healthCheckStatus) {
69         this.healthCheckStatus = healthCheckStatus;
70     }
71
72     public List<HealthCheckInfo> getComponentsInfo() {
73         return componentsInfo;
74     }
75
76     public void setComponentsInfo(List<HealthCheckInfo> componentsInfo) {
77         this.componentsInfo = componentsInfo;
78     }
79
80     public String getVersion() {
81         return version;
82     }
83
84     public void setVersion(String version) {
85         this.version = version;
86     }
87
88     public String getDescription() {
89         return description;
90     }
91
92     public void setDescription(String description) {
93         this.description = description;
94     }
95
96     public enum HealthCheckStatus {
97         UP, DOWN, UNKNOWN;
98     }
99
100     @Override
101     public String toString() {
102         return "HealthCheckInfo [healthCheckComponent=" + healthCheckComponent + ", healthCheckStatus="
103                 + healthCheckStatus + ", version=" + version + ", description=" + description + ", componentsInfo="
104                 + componentsInfo + "]";
105     }
106
107     public static void main(String[] args) {
108         String des = "[{healthCheckComponent=BE4, healthCheckStatus=UP, version=0.0.1-SNAPSHOT, description=OK}, {healthCheckComponent=BE, healthCheckStatus=UP, version=1710.0.0-SNAPSHOT, description=OK}, {healthCheckComponent=BE5, healthCheckStatus=UP, version=2.1.9, description=OK}]";
109         Type listType = new TypeToken<List<HealthCheckInfo>>() {
110         }.getType();
111         List<HealthCheckInfo> componentsInfo = new Gson().fromJson(des.toString(), listType);
112         System.out.println(componentsInfo.toString());
113     }
114 }