mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Solving nullable
Signed-off-by: Gaël L'hopital <gael@lhopital.org>
This commit is contained in:
parent
838816c033
commit
ec0bb2f463
@ -115,7 +115,6 @@ public class AirParifDto {
|
|||||||
private static ZoneId DEFAULT_ZONE = ZoneId.of("Europe/Paris");
|
private static ZoneId DEFAULT_ZONE = ZoneId.of("Europe/Paris");
|
||||||
|
|
||||||
public List<Pollens> data = List.of();
|
public List<Pollens> data = List.of();
|
||||||
private @Nullable Set<ZonedDateTime> validities;
|
|
||||||
private @Nullable ZonedDateTime beginValidity;
|
private @Nullable ZonedDateTime beginValidity;
|
||||||
private @Nullable ZonedDateTime endValidity;
|
private @Nullable ZonedDateTime endValidity;
|
||||||
|
|
||||||
@ -124,21 +123,15 @@ public class AirParifDto {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Set<ZonedDateTime> getValidities() {
|
private Set<ZonedDateTime> getValidities() {
|
||||||
final Set<ZonedDateTime> local;
|
Set<ZonedDateTime> validities = new TreeSet<>();
|
||||||
if (validities != null) {
|
|
||||||
local = validities;
|
|
||||||
} else {
|
|
||||||
local = new TreeSet<ZonedDateTime>();
|
|
||||||
getData().ifPresent(pollens -> {
|
getData().ifPresent(pollens -> {
|
||||||
Matcher matcher = PATTERN.matcher(pollens.periode);
|
Matcher matcher = PATTERN.matcher(pollens.periode);
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
local.add(LocalDate.parse(matcher.group(), FORMATTER).atStartOfDay(DEFAULT_ZONE));
|
validities.add(LocalDate.parse(matcher.group(), FORMATTER).atStartOfDay(DEFAULT_ZONE));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
validities = local;
|
|
||||||
}
|
|
||||||
|
|
||||||
return local;
|
return validities;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ZonedDateTime> getBeginValidity() {
|
public Optional<ZonedDateTime> getBeginValidity() {
|
||||||
|
Loading…
Reference in New Issue
Block a user