DateTime now = new DateTime();
BigDecimal warn = check.getWarn();
BigDecimal error = check.getError();
AlertType worstState = AlertType.UNKNOWN;
List<Alert> interestingAlerts = new ArrayList<Alert>();
for (Entry<String, Optional<BigDecimal>> entry : targetValues.entrySet()) {
String target = entry.getKey();
Optional<BigDecimal> value = entry.getValue();
if (!value.isPresent()) {
LOGGER.warn("No value present for {}", target);
continue;
}
BigDecimal currentValue = value.get();
Alert lastAlert = alertsStore.getLastAlertForTargetOfCheck(target, check.getId());
AlertType lastState;
if (lastAlert == null) {
lastState = AlertType.OK;
} else {
lastState = lastAlert.getToType();
}
AlertType currentState = valueChecker.checkValue(currentValue, warn, error);
if (currentState.isWorseThan(worstState)) {
worstState = currentState;
}
if (isStillOk(lastState, currentState)) {
continue;