Replaced all tabs with spaces in java and pom.xml
[so.git] / common / src / main / java / org / onap / so / utils / CheckResults.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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.onap.so.utils;
22
23
24
25 import java.util.ArrayList;
26 import java.util.List;
27 import javax.xml.bind.annotation.XmlAttribute;
28 import javax.xml.bind.annotation.XmlElement;
29 import javax.xml.bind.annotation.XmlRootElement;
30
31 @XmlRootElement(name = "checkresults")
32 public class CheckResults {
33
34     @XmlElement(name = "checkresult")
35     private List<CheckResult> results;
36
37     public CheckResults() {
38         results = new ArrayList<>();
39     }
40
41     public List<CheckResult> getResults() {
42         return results;
43     }
44
45     public void addHostCheckResult(String hostname, int state, String output) {
46         CheckResult newResult = new CheckResult();
47         newResult.setType("host");
48         newResult.setHostname(hostname);
49         newResult.setState(state);
50         newResult.setOutput(output);
51         results.add(newResult);
52     }
53
54     public void addServiceCheckResult(String hostname, String servicename, int state, String output) {
55         CheckResult newResult = new CheckResult();
56         newResult.setType("service");
57         newResult.setHostname(hostname);
58         newResult.setServicename(servicename);
59         newResult.setState(state);
60         newResult.setOutput(output);
61         results.add(newResult);
62     }
63
64     public static class CheckResult {
65
66         private String type;
67         private String hostname;
68         private String servicename;
69         private int state;
70         private String output;
71
72         @XmlAttribute(required = true)
73         public String getType() {
74             return type;
75         }
76
77         public void setType(String type) {
78             this.type = type;
79         }
80
81         @XmlElement(required = true)
82         public String getHostname() {
83             return hostname;
84         }
85
86         public void setHostname(String hostname) {
87             this.hostname = hostname;
88         }
89
90         @XmlElement(required = false)
91         public String getServicename() {
92             return servicename;
93         }
94
95         public void setServicename(String servicename) {
96             this.servicename = servicename;
97         }
98
99         @XmlElement(required = true)
100         public int getState() {
101             return state;
102         }
103
104         public void setState(int state) {
105             this.state = state;
106         }
107
108         @XmlElement(required = true)
109         public String getOutput() {
110             return output;
111         }
112
113         public void setOutput(String output) {
114             this.output = output;
115         }
116     }
117 }