Source:
<code>public void handleGetStatusResponse(final com.alliander.osgp.dto.valueobjects.DeviceStatusDto deviceStatusDto, final DomainType allowedDomainType, final String deviceIdentification, final String organisationIdentification, final String correlationUid, final String messageType, final ResponseMessageResultType deviceResult, final OsgpException exception) { LOGGER.info("handleResponse for MessageType: {}", messageType); final GetStatusResponse response = new GetStatusResponse(); response.setOsgpException(exception); response.setResult(deviceResult); if (deviceResult == ResponseMessageResultType.NOT_OK || exception != null) { LOGGER.error("Device Response not ok.", exception); } else { final DeviceStatus status = this.domainCoreMapper.map(deviceStatusDto, DeviceStatus.class); try { final Device dev = this.deviceDomainService.searchDevice(deviceIdentification); if (LightMeasurementDevice.LMD_TYPE.equals(dev.getDeviceType())) { this.handleLmd(status, response); } else { this.handleSsld(deviceIdentification, status, allowedDomainType, response); } } catch (final FunctionalException e) { LOGGER.error("Caught FunctionalException", e); } } <START> this.webServiceResponseMessageSender.send(ResponseMessage.newResponseMessageBuilder() <END> .withCorrelationUid(correlationUid).withOrganisationIdentification(organisationIdentification) .withDeviceIdentification(deviceIdentification).withResult(response.getResult()) .withOsgpException(response.getOsgpException()).withDataObject(response.getDeviceStatusMapped()) .build()); }</code><technical_language>Extract building of ResponseMessage variable (in eclipse, select text, right-click > refactor > extract local variable / select code + shift+alt+L). This code a bit more readable, especially passing in other besides ResponseMessage</technical_language>

Target:
public void handleGetStatusResponse(final com.alliander.osgp.dto.valueobjects.DeviceStatusDto deviceStatusDto, final DomainType allowedDomainType, final String deviceIdentification, final String organisationIdentification, final String correlationUid, final String messageType, final ResponseMessageResultType deviceResult, final OsgpException exception) { LOGGER.info("handleResponse for MessageType: {}", messageType); final GetStatusResponse response = new GetStatusResponse(); response.setOsgpException(exception); response.setResult(deviceResult); if (deviceResult == ResponseMessageResultType.NOT_OK || exception != null) { LOGGER.error("Device Response not ok.", exception); } else { final DeviceStatus status = this.domainCoreMapper.map(deviceStatusDto, DeviceStatus.class); try { final Device dev = this.deviceDomainService.searchDevice(deviceIdentification); if (LightMeasurementDevice.LMD_TYPE.equals(dev.getDeviceType())) { this.handleLmd(status, response); } else { this.handleSsld(deviceIdentification, status, allowedDomainType, response); } } catch (final FunctionalException e) { LOGGER.error("Caught FunctionalException", e); } } ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder() .withCorrelationUid(correlationUid).withOrganisationIdentification(organisationIdentification) .withDeviceIdentification(deviceIdentification).withResult(response.getResult()) .withOsgpException(response.getOsgpException()).withDataObject(response.getDeviceStatusMapped()) .build(); this.webServiceResponseMessageSender.send(responseMessage); }