class GenericReportUnitResourceConverter extends DataSourceHolderResourceConverter<ServerReportUnitType, ClientReportUnitType> {

    @Override
    protected ServerReportUnitType resourceSpecificFieldsToServer(ClientReportUnitType clientObject, ServerReportUnitType resultToUpdate, List<Exception> exceptions, ToServerConversionOptions options) throws IllegalParameterValueException, MandatoryParameterNotFoundException {
        resultToUpdate.setAlwaysPromptControls(clientObject.isAlwaysPromptControls());
        final byte controlsLayout;
        if (clientObject.getControlsLayout() != null) {
            switch (clientObject.getControlsLayout()) {
                case popupScreen:
                    controlsLayout = ReportUnit.LAYOUT_POPUP_SCREEN;
                    break;
                case separatePage:
                    controlsLayout = ReportUnit.LAYOUT_SEPARATE_PAGE;
                    break;
                case inPage:
                    controlsLayout = ReportUnit.LAYOUT_IN_PAGE;
                    break;
                case topOfPage:
                    controlsLayout = ReportUnit.LAYOUT_TOP_OF_PAGE;
                    break;
                default:
                    controlsLayout = ReportUnit.LAYOUT_POPUP_SCREEN;
            }
            resultToUpdate.setControlsLayout(controlsLayout);
        }
        resultToUpdate.setInputControlRenderingView(clientObject.getInputControlRenderingView());
        resultToUpdate.setReportRenderingView(clientObject.getReportRenderingView());
        resultToUpdate.setQuery(resourceReferenceConverterProvider.getConverterForType(ClientReferenceableQuery.class)
                .toServer(clientObject.getQuery(), resultToUpdate.getQuery(), options));
        resultToUpdate.setMainReport(resourceReferenceConverterProvider.getConverterForType(ClientReferenceableFile.class)
                .addReferenceRestriction(new ResourceReferenceConverter.FileTypeRestriction(ClientFile.FileType.jrxml))
                .toServer(clientObject.getJrxml(), resultToUpdate.getMainReport(), options));
        List<ResourceReference> inputControls = null;
        final List<ClientReferenceableInputControl> clientInputControls = clientObject.getInputControls();
        if (clientInputControls != null && !clientInputControls.isEmpty()) {
            inputControls = new ArrayList<ResourceReference>(clientInputControls.size());
            final ResourceReferenceConverter<ClientReferenceableInputControl> inputControlReferenceConverter =
                    resourceReferenceConverterProvider.getConverterForType(ClientReferenceableInputControl.class);
            for (ClientReferenceableInputControl inputControlReference : clientInputControls) {
                inputControls.add(inputControlReferenceConverter.toServer(inputControlReference,
                        findReference(resultToUpdate.getInputControls(), inputControlReference.getUri()), options));
            }
        }
        resultToUpdate.setInputControls(inputControls);
        // Raw List is used in core classes, but it is of type List<ResourceReference>. So, cast is safe.
        @SuppressWarnings("unchecked")
        final List<ResourceReference> resources = resultToUpdate.getResources();
        resultToUpdate.setResources(convertResourcesToServer(clientObject.getFiles(), resources, options));
        return resultToUpdate;
    }

}