La Carbonell :
I have this couple of functions and I would like to know if it is possible to pass the parameter deviceEvent.hasAlarm()
to .map(this::sendSMS)
private void processAlarm (DeviceEvent deviceEvent) {
notificationsWithGuardians.stream()
.filter (notification -> notification.getLevels().contains(deviceEvent.getDeviceMessage().getLevel()))
.map(this::sendSMS)
.map(this::sendEmail);
}
private DeviceAlarmNotification sendSMS (DeviceAlarmNotification notification, DeviceEvent deviceEvent) {
if (deviceEvent.hasAlarm()) {
}
return notification;
}
Andy Turner :
Use a lambda instead of the method reference.
// ...
.map(n -> sendSMS(n, deviceEvent))
// ...
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=436115&siteId=1