mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
SAT solving
Signed-off-by: Gaël L'hopital <gael@lhopital.org>
This commit is contained in:
parent
3bd53b764a
commit
838816c033
@ -101,8 +101,7 @@ public class AirParifIconProvider implements IconProvider {
|
||||
if (POLLEN_ICONS.contains(category) && state != null) {
|
||||
try {
|
||||
int ordinal = Integer.valueOf(state);
|
||||
PollenAlertLevel alertLevel = PollenAlertLevel.AS_SET.stream()
|
||||
.filter(pal -> pal.riskLevel == ordinal).findFirst().orElse(PollenAlertLevel.UNKNOWN);
|
||||
PollenAlertLevel alertLevel = PollenAlertLevel.valueOf(ordinal);
|
||||
result = result.replaceAll(NEUTRAL_COLOR, alertLevel.color);
|
||||
} catch (NumberFormatException ignore) {
|
||||
}
|
||||
|
@ -124,11 +124,11 @@ public class AirParifDto {
|
||||
}
|
||||
|
||||
private Set<ZonedDateTime> getValidities() {
|
||||
Set<ZonedDateTime> local;
|
||||
final Set<ZonedDateTime> local;
|
||||
if (validities != null) {
|
||||
local = validities;
|
||||
} else {
|
||||
local = new TreeSet<>();
|
||||
local = new TreeSet<ZonedDateTime>();
|
||||
getData().ifPresent(pollens -> {
|
||||
Matcher matcher = PATTERN.matcher(pollens.periode);
|
||||
while (matcher.find()) {
|
||||
|
@ -13,6 +13,7 @@
|
||||
package org.openhab.binding.airparif.internal.api;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
|
||||
@ -42,4 +43,9 @@ public enum PollenAlertLevel {
|
||||
this.riskLevel = riskLevel;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public static PollenAlertLevel valueOf(int ordinal) {
|
||||
return Objects
|
||||
.requireNonNull(AS_SET.stream().filter(pal -> pal.riskLevel == ordinal).findFirst().orElse(UNKNOWN));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user