2 * Copyright (c) 2010-2020 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.dwdunwetter.internal.data;
15 import java.util.Comparator;
17 import org.apache.commons.lang.ObjectUtils;
20 * Comperator to sort a Warning first by Severity, second by the onSet date.
22 * @author Martin Koehler - Initial contribution
24 public class SeverityComparator implements Comparator<DwdWarningData> {
27 public int compare(DwdWarningData o1, DwdWarningData o2) {
28 Comparator.comparingInt(d -> ((DwdWarningData) d).getSeverity().getOrder());
29 Comparator.comparing(DwdWarningData::getOnset);
31 int result = Integer.compare(o1.getSeverity().getOrder(), o2.getSeverity().getOrder());
33 result = ObjectUtils.compare(o1.getOnset(), o2.getOnset());