/** * Filters open / closed alerts depending on the given boolean indicator. * * @param alerts * Alerts to filter. * @param open * Indicator whether open alerts should stay or closed. If true, the results will * contain only open alerts, otherwise only closed alerts. * @return Filtered list of alerts. */ private List<Alert> filterAlerts(List<Alert> alerts, boolean open) { List<Alert> filteredAlerts = new ArrayList<>(); for (Alert alert : alerts) { if (alert.isOpen() == open) { filteredAlerts.add(alert); } } return filteredAlerts; } }
/** * Returns string representation of an alert. * * @param alert * {@link Alert} instance to create string for. * @return Returns string representation of an alert. */ public static String getAlertDescription(Alert alert) { String closing = alert.isOpen() ? "Open" : DateFormat.getDateTimeInstance().format(new Date(alert.getStopTimestamp())); return alert.getAlertingDefinition().getName() + " (" + DateFormat.getDateTimeInstance().format(new Date(alert.getStartTimestamp())) + " - " + closing + ")"; }