Open Kilda Java Documentation
HealthCheck.java
Go to the documentation of this file.
1 /* Copyright 2017 Telstra Open Source
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package org.openkilda.messaging.model;
17 
18 import static com.google.common.base.MoreObjects.toStringHelper;
19 
21 
22 import com.fasterxml.jackson.annotation.JsonCreator;
23 import com.fasterxml.jackson.annotation.JsonInclude;
24 import com.fasterxml.jackson.annotation.JsonProperty;
25 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
26 
27 import java.io.Serializable;
28 import java.util.Map;
29 import java.util.Objects;
30 
34 @JsonSerialize
35 @JsonInclude(JsonInclude.Include.NON_NULL)
36 public class HealthCheck implements Serializable {
40  private static final long serialVersionUID = 1L;
41 
45  @JsonProperty("name")
46  private String name;
47 
51  @JsonProperty("version")
52  private String version;
53 
57  @JsonProperty("description")
58  private String description;
59 
63  @JsonProperty("components")
64  private Map<String, String> components;
65 
69  public HealthCheck() {
70  }
71 
80  @JsonCreator
81  public HealthCheck(@JsonProperty("name") String name,
82  @JsonProperty("version") String version,
83  @JsonProperty("description") String description,
84  @JsonProperty("components") Map<String, String> components) {
85  setName(name);
86  setServiceVersion(version);
87  setDescription(description);
88  setComponents(components);
89  }
90 
96  public String getName() {
97  return name;
98  }
99 
105  public void setName(final String name) {
106  this.name = name;
107  }
108 
114  public String getVersion() {
115  return version;
116  }
117 
123  public void setServiceVersion(final String version) {
124  this.version = version;
125  }
126 
132  public String getDescription() {
133  return description;
134  }
135 
141  public void setDescription(final String description) {
142  this.description = description;
143  }
144 
150  public Map<String, String> getComponents() {
151  return components;
152  }
153 
159  public void setComponents(Map<String, String> components) {
160  this.components = components;
161  }
162 
166  @Override
167  public String toString() {
168  return toStringHelper(this)
169  .add("name", name)
170  .add("version", version)
171  .add("description", description)
172  .add("components", components)
173  .toString();
174  }
175 
179  @Override
180  public boolean equals(Object obj) {
181  if (this == obj) {
182  return true;
183  }
184 
185  if (obj == null || !(obj instanceof HealthCheck)) {
186  return false;
187  }
188 
189  HealthCheck that = (HealthCheck) obj;
190  return Objects.equals(this.getName(), that.getName())
191  && Objects.equals(this.getVersion(), that.getVersion())
192  && Objects.equals(this.getDescription(), that.getDescription())
193  && Objects.equals(this.getComponents(), that.getComponents());
194  }
195 
199  @Override
200  public int hashCode() {
201  return Objects.hash(name, version, description, components);
202  }
203 
209  public boolean hasNonOperational() {
210  return components.values().stream().anyMatch(Utils.HEALTH_CHECK_NON_OPERATIONAL_STATUS::equals);
211  }
212 }
name
Definition: setup.py:24
HealthCheck(@JsonProperty("name") String name, @JsonProperty("version") String version, @JsonProperty("description") String description, @JsonProperty("components") Map< String, String > components)
description
Definition: setup.py:26
void setDescription(final String description)
void setServiceVersion(final String version)
version
Definition: setup.py:25
void setComponents(Map< String, String > components)