Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[netatmo] Fix ClassCastException #16573

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

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;
Expand Down Expand Up @@ -107,7 +106,7 @@ void setThingStatus(ThingStatus thingStatus, ThingStatusDetail thingStatusDetail
}

default void expireData() {
getCapabilities().values().forEach(cap -> cap.expireData());
getCapabilities().values().forEach(Capability::expireData);
}

default String getId() {
Expand Down Expand Up @@ -152,13 +151,12 @@ default List<CommonInterface> getAllActiveChildren(Bridge bridge) {
}

default List<CommonInterface> getActiveChildren() {
Thing thing = getThing();
if (thing instanceof Bridge bridge) {
return 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();
return getThing() instanceof Bridge bridge
? bridge.getThings().stream().filter(Thing::isEnabled)
.filter(th -> th.getStatusInfo().getStatusDetail() != ThingStatusDetail.BRIDGE_OFFLINE)
.map(Thing::getHandler).filter(CommonInterface.class::isInstance)
.map(CommonInterface.class::cast).toList()
: List.of();
}

default Stream<CommonInterface> getActiveChildren(FeatureArea area) {
Expand Down Expand Up @@ -207,7 +205,7 @@ default void commonHandleCommand(ChannelUID channelUID, Command command) {
}

default void proceedWithUpdate() {
updateReadings().forEach(dataSet -> setNewData(dataSet));
updateReadings().forEach(this::setNewData);
}

default List<NAObject> updateReadings() {
Expand Down Expand Up @@ -244,7 +242,6 @@ default void commonDispose() {
}

default void removeChannels(List<Channel> channels) {
ThingBuilder builder = editThing().withoutChannels(channels);
updateThing(builder.build());
updateThing(editThing().withoutChannels(channels).build());
}
}