I have this piece of code, to extract from a List of DeviceEvents the ones with some condition
List<DeviceEvent> deviceEvents = new ArrayList<>();
deviceEventService
.findAll(loggedInUser())
.filter(this::isAlarmMessage)
.iterator()
.forEachRemaining(deviceEvents::add);
private boolean isAlarmMessage (DeviceEvent deviceEvent) {
return AlarmLevelEnum.HIGH == deviceEvent.getDeviceMessage().getLevel();
}
but I got this compilation error:
The method filter(this::isAlarmMessage) is undefined for the type
Iterable<DeviceEvent>
findAll
returns aIterable<DeviceEvent>