Sync Integ to Master
[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 java.lang.reflect.Type;
24 import java.util.List;
25
26 import com.google.gson.Gson;
27 import com.google.gson.reflect.TypeToken;
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 HealthCheckComponent {
97                 FE, BE, TITAN, DE, ON_BOARDING, CASSANDRA, DCAE,
98                 CAS, ZU;//Amdocs components
99         }*/
100
101         public enum HealthCheckStatus {
102                 UP, DOWN, UNKNOWN;
103         }
104
105         @Override
106         public String toString() {
107                 return "HealthCheckInfo [healthCheckComponent=" + healthCheckComponent + ", healthCheckStatus="
108                                 + healthCheckStatus + ", version=" + version + ", description=" + description + ", componentsInfo="
109                                 + componentsInfo + "]";
110         }
111         
112         public static void main(String[] args) {
113                 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}]";
114                 Type listType = new TypeToken<List<HealthCheckInfo>>(){}.getType();
115                 List<HealthCheckInfo> componentsInfo = new Gson().fromJson(des.toString(), listType);
116                 System.out.println(componentsInfo.toString());
117         }
118 }