我有这几个函数,我想知道是否可以将参数 deviceEvent.hasAlarm()
传递给 .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;
}
原文由 La Carbonell 发布,翻译遵循 CC BY-SA 4.0 许可协议
使用 lambda 而不是方法引用。