class GenericReportUnitResourceConverter extends DataSourceHolderResourceConverter<ServerReportUnitType, ClientReportUnitType> {

    @Override
    protected ClientReportUnitType resourceSpecificFieldsToClient(ClientReportUnitType client, ServerReportUnitType serverObject, ToClientConversionOptions options) {
        client.setAlwaysPromptControls(serverObject.isAlwaysPromptControls());
        final ClientReportUnit.ControlsLayoutType controlsLayout;
        switch (serverObject.getControlsLayout()) {
            case ReportUnit.LAYOUT_POPUP_SCREEN:
                controlsLayout = ClientReportUnit.ControlsLayoutType.popupScreen;
                break;
            case ReportUnit.LAYOUT_SEPARATE_PAGE:
                controlsLayout = ClientReportUnit.ControlsLayoutType.separatePage;
                break;
            case ReportUnit.LAYOUT_IN_PAGE:
                controlsLayout = ClientReportUnit.ControlsLayoutType.inPage;
                break;
            case ReportUnit.LAYOUT_TOP_OF_PAGE:
                controlsLayout = ClientReportUnit.ControlsLayoutType.topOfPage;
                break;
            default:
                controlsLayout = ClientReportUnit.ControlsLayoutType.popupScreen;
        }
        client.setControlsLayout(controlsLayout);
        client.setInputControlRenderingView(serverObject.getInputControlRenderingView());
        client.setReportRenderingView(serverObject.getReportRenderingView());
        client.setQuery(resourceReferenceConverterProvider.getConverterForType(ClientReferenceableQuery.class)
                .toClient(serverObject.getQuery(), options));
        // don't need to add restriction for JRXML type of file.
        // In case of toClient conversion restrictions are not called.
        client.setJrxml(resourceReferenceConverterProvider.getConverterForType(ClientReferenceableFile.class)
                .toClient(serverObject.getMainReport(), options));
        List<ClientReferenceableInputControl> inputControls = null;
        final List<ResourceReference> serverInputControls = serverObject.getInputControls();
        if (serverInputControls != null && !serverInputControls.isEmpty()) {
            inputControls = new ArrayList<ClientReferenceableInputControl>(serverInputControls.size());
            final ResourceReferenceConverter<ClientReferenceableInputControl> inputControlResourceReferenceConverter =
                    resourceReferenceConverterProvider.getConverterForType(ClientReferenceableInputControl.class);
            for (ResourceReference inputControlReference : serverInputControls) {
                inputControls.add(inputControlResourceReferenceConverter.toClient(inputControlReference, options));
            }
        }
        client.setInputControls(inputControls);
        // core module uses raw List, but there is List<ResourceReference>. So, cast is safe.
        @SuppressWarnings("unchecked")
        final List<ResourceReference> resources = serverObject.getResources();
        client.setFiles(convertResourcesToClient(resources, options));
        return client;
    }

}