Source:
private void handleSwitchDeviceEvents(final Device device, final List<Event> switchDeviceEvents) throws UnknownEntityException { LOGGER.info("handleSwitchDeviceEvents() called for device: with lightSwitchingEvents.size(): {}", device.getDeviceIdentification(), switchDeviceEvents.size()); if (switchDeviceEvents.isEmpty()) { return; } final Ssld ssld = this.eventNotificationHelperService.findSsld(device.getId()); final Set<Integer> indexesLightRelays = new TreeSet<>(); final Set<Integer> indexesTariffRelays = new TreeSet<>(); for (final DeviceOutputSetting deviceOutputSetting : ssld.getOutputSettings()) { if (deviceOutputSetting.getOutputType().equals(RelayType.LIGHT)) { indexesLightRelays.add(deviceOutputSetting.getExternalId()); } if (deviceOutputSetting.getOutputType().equals(RelayType.TARIFF)) { indexesTariffRelays.add(deviceOutputSetting.getExternalId()); } } this.printRelayIndexes(indexesLightRelays, indexesTariffRelays, device.getDeviceIdentification()); final Map<Integer, RelayStatus> lastRelayStatusPerIndex = new TreeMap<>(); for (final Event lightSwitchingEvent : switchDeviceEvents) { final Integer index = lightSwitchingEvent.getIndex(); if (index == 0) { this.handleLightSwitchingEventForIndex0(indexesLightRelays, device, lightSwitchingEvent, lastRelayStatusPerIndex); } else { this.createRelayStatus(device, lightSwitchingEvent, index, lastRelayStatusPerIndex); } } this.printRelayStatuses(lastRelayStatusPerIndex, device.getDeviceIdentification()); if (!lastRelayStatusPerIndex.isEmpty()) { LOGGER.info("calling ssld.updateRelayStatuses() for device: with lastRelayStatusPerIndex.size(): {}", ssld.getDeviceIdentification(), lastRelayStatusPerIndex.size()); ssld.updateRelayStatusses(lastRelayStatusPerIndex); this.eventNotificationHelperService.saveSsld(ssld); this.sendRequestMessageToDomainCore(RELAY_STATUS_UPDATED_EVENTS, ssld.getDeviceIdentification(), null); } }

Target:
private void handleSwitchDeviceEvents(final Device device, final List<Event> switchDeviceEvents) throws UnknownEntityException { LOGGER.info("handleSwitchDeviceEvents() called for device: with lightSwitchingEvents.size(): {}", device.getDeviceIdentification(), switchDeviceEvents.size()); if (switchDeviceEvents.isEmpty()) { return; } final Ssld ssld = this.eventNotificationHelperService.findSsld(device.getId()); final Set<Integer> indexesLightRelays = new TreeSet<>(); final Set<Integer> indexesTariffRelays = new TreeSet<>(); for (final DeviceOutputSetting deviceOutputSetting : ssld.getOutputSettings()) { if (deviceOutputSetting.getOutputType().equals(RelayType.LIGHT)) { indexesLightRelays.add(deviceOutputSetting.getExternalId()); } if (deviceOutputSetting.getOutputType().equals(RelayType.TARIFF) || deviceOutputSetting.getOutputType().equals(RelayType.TARIFF_REVERSED)) { indexesTariffRelays.add(deviceOutputSetting.getExternalId()); } } this.printRelayIndexes(indexesLightRelays, indexesTariffRelays, device.getDeviceIdentification()); final Map<Integer, RelayStatus> lastRelayStatusPerIndex = new TreeMap<>(); for (final Event lightSwitchingEvent : switchDeviceEvents) { final Integer index = lightSwitchingEvent.getIndex(); if (index == 0) { this.handleLightSwitchingEventForIndex0(indexesLightRelays, device, lightSwitchingEvent, lastRelayStatusPerIndex); } else { this.createRelayStatus(device, lightSwitchingEvent, index, lastRelayStatusPerIndex); } } this.printRelayStatuses(lastRelayStatusPerIndex, device.getDeviceIdentification()); if (!lastRelayStatusPerIndex.isEmpty()) { LOGGER.info("calling ssld.updateRelayStatuses() for device: with lastRelayStatusPerIndex.size(): {}", ssld.getDeviceIdentification(), lastRelayStatusPerIndex.size()); ssld.updateRelayStatusses(lastRelayStatusPerIndex); this.eventNotificationHelperService.saveSsld(ssld); this.sendRequestMessageToDomainCore(RELAY_STATUS_UPDATED_EVENTS, ssld.getDeviceIdentification(), null); } }