Pre-validation of the various fields to make sure they're valid @param details a map to hold detailed error message. If null then the errors will be logged @return true if data point is valid, otherwise false
(final List<Map<String, Object>> details)
| 173 | * @return true if data point is valid, otherwise false |
| 174 | */ |
| 175 | public boolean validate(final List<Map<String, Object>> details) { |
| 176 | if (this.getMetric() == null || this.getMetric().isEmpty()) { |
| 177 | if (details != null) { |
| 178 | details.add(getHttpDetails("Metric name was empty")); |
| 179 | } |
| 180 | LOG.warn("Metric name was empty: " + this); |
| 181 | return false; |
| 182 | } |
| 183 | |
| 184 | //TODO add blacklisted metric validatin here too |
| 185 | |
| 186 | if (this.getTimestamp() <= 0) { |
| 187 | if (details != null) { |
| 188 | details.add(getHttpDetails("Invalid timestamp")); |
| 189 | } |
| 190 | LOG.warn("Invalid timestamp: " + this); |
| 191 | return false; |
| 192 | } |
| 193 | |
| 194 | if (this.getValue() == null || this.getValue().isEmpty()) { |
| 195 | if (details != null) { |
| 196 | details.add(getHttpDetails("Empty value")); |
| 197 | } |
| 198 | LOG.warn("Empty value: " + this); |
| 199 | return false; |
| 200 | } |
| 201 | |
| 202 | if (this.getTags() == null || this.getTags().size() < 1) { |
| 203 | if (details != null) { |
| 204 | details.add(getHttpDetails("Missing tags")); |
| 205 | } |
| 206 | LOG.warn("Missing tags: " + this); |
| 207 | return false; |
| 208 | } |
| 209 | return true; |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * Creates a map with an error message and this data point to return |
nothing calls this directly
no test coverage detected