Source:
<code>public void handleGetPowerUsageHistoryResponse( final PowerUsageHistoryResponseMessageDataContainerDto powerUsageHistoryResponseMessageDataContainerDto, final String organisationIdentification, final String deviceIdentification, final String correlationUid, final String messageType, final ResponseMessageResultType deviceResult, final OsgpException exception) { LOGGER.info("handleResponse called for device: for organisation: for messageType: {}", deviceIdentification, organisationIdentification, messageType); ResponseMessageResultType result = ResponseMessageResultType.OK; OsgpException osgpException = exception; PowerUsageHistoryResponse powerUsageHistoryResponse = null; try { if (deviceResult == ResponseMessageResultType.NOT_OK || osgpException != null) { LOGGER.error("Device Response not ok.", osgpException); throw osgpException; } powerUsageHistoryResponse = new PowerUsageHistoryResponse(this.domainCoreMapper.mapAsList( powerUsageHistoryResponseMessageDataContainerDto.getPowerUsageData(), PowerUsageData.class)); } catch (final Exception e) { LOGGER.error("Unexpected Exception", e); result = ResponseMessageResultType.NOT_OK; osgpException = new TechnicalException(ComponentType.UNKNOWN, "Exception occurred while getting device power usage history", e); } <START> this.webServiceResponseMessageSender.send( <END> ResponseMessage.newResponseMessageBuilder().withCorrelationUid(correlationUid) .withOrganisationIdentification(organisationIdentification) .withDeviceIdentification(deviceIdentification).withResult(result) .withOsgpException(osgpException).withDataObject(powerUsageHistoryResponse).build(), this.getPowerUsageHistoryResponseTimeToLive); }</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 handleGetPowerUsageHistoryResponse( final PowerUsageHistoryResponseMessageDataContainerDto powerUsageHistoryResponseMessageDataContainerDto, final String organisationIdentification, final String deviceIdentification, final String correlationUid, final String messageType, final ResponseMessageResultType deviceResult, final OsgpException exception) { LOGGER.info("handleResponse called for device: for organisation: for messageType: {}", deviceIdentification, organisationIdentification, messageType); ResponseMessageResultType result = ResponseMessageResultType.OK; OsgpException osgpException = exception; PowerUsageHistoryResponse powerUsageHistoryResponse = null; try { if (deviceResult == ResponseMessageResultType.NOT_OK || osgpException != null) { LOGGER.error("Device Response not ok.", osgpException); throw osgpException; } powerUsageHistoryResponse = new PowerUsageHistoryResponse(this.domainCoreMapper.mapAsList( powerUsageHistoryResponseMessageDataContainerDto.getPowerUsageData(), PowerUsageData.class)); } catch (final Exception e) { LOGGER.error("Unexpected Exception", e); result = ResponseMessageResultType.NOT_OK; osgpException = new TechnicalException(ComponentType.UNKNOWN, "Exception occurred while getting device power usage history", e); } final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder() .withCorrelationUid(correlationUid).withOrganisationIdentification(organisationIdentification) .withDeviceIdentification(deviceIdentification).withResult(result).withOsgpException(osgpException) .withDataObject(powerUsageHistoryResponse).build(); this.webServiceResponseMessageSender.send(responseMessage, this.getPowerUsageHistoryResponseTimeToLive); }