mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Enhance getActiveChildren() (#16573)
Signed-off-by: clinique <gael@lhopital.org> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
b861c02386
commit
8e4a8314e2
@ -14,7 +14,6 @@ package org.openhab.binding.netatmo.internal.handler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.stream.Stream;
|
||||
@ -107,7 +106,7 @@ public interface CommonInterface {
|
||||
}
|
||||
|
||||
default void expireData() {
|
||||
getCapabilities().values().forEach(cap -> cap.expireData());
|
||||
getCapabilities().values().forEach(Capability::expireData);
|
||||
}
|
||||
|
||||
default String getId() {
|
||||
@ -152,13 +151,12 @@ public interface CommonInterface {
|
||||
}
|
||||
|
||||
default List<CommonInterface> getActiveChildren() {
|
||||
Thing thing = getThing();
|
||||
if (thing instanceof Bridge bridge) {
|
||||
return bridge.getThings().stream().filter(Thing::isEnabled)
|
||||
return getThing() instanceof Bridge bridge
|
||||
? bridge.getThings().stream().filter(Thing::isEnabled)
|
||||
.filter(th -> th.getStatusInfo().getStatusDetail() != ThingStatusDetail.BRIDGE_OFFLINE)
|
||||
.map(Thing::getHandler).filter(Objects::nonNull).map(CommonInterface.class::cast).toList();
|
||||
}
|
||||
return List.of();
|
||||
.map(Thing::getHandler).filter(CommonInterface.class::isInstance)
|
||||
.map(CommonInterface.class::cast).toList()
|
||||
: List.of();
|
||||
}
|
||||
|
||||
default Stream<CommonInterface> getActiveChildren(FeatureArea area) {
|
||||
@ -207,7 +205,7 @@ public interface CommonInterface {
|
||||
}
|
||||
|
||||
default void proceedWithUpdate() {
|
||||
updateReadings().forEach(dataSet -> setNewData(dataSet));
|
||||
updateReadings().forEach(this::setNewData);
|
||||
}
|
||||
|
||||
default List<NAObject> updateReadings() {
|
||||
@ -244,7 +242,6 @@ public interface CommonInterface {
|
||||
}
|
||||
|
||||
default void removeChannels(List<Channel> channels) {
|
||||
ThingBuilder builder = editThing().withoutChannels(channels);
|
||||
updateThing(builder.build());
|
||||
updateThing(editThing().withoutChannels(channels).build());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user