class GenericReportUnitResourceConverter extends DataSourceHolderResourceConverter<ServerReportUnitType, ClientReportUnitType> {

    protected Map<String, ClientReferenceableFile> convertResourcesToClient(List<ResourceReference> serverResources, ToClientConversionOptions options) {
        Map<String, ClientReferenceableFile> result = null;
        if (serverResources != null && !serverResources.isEmpty()) {
            ResourceReferenceConverter<ClientReferenceableFile> fileResourceReferenceConverter =
                    resourceReferenceConverterProvider.getConverterForType(ClientReferenceableFile.class);
            result = new HashMap<String, ClientReferenceableFile>(serverResources.size());
            for (ResourceReference reference : serverResources) {
                if (reference.isLocal()) {
                    // partially process file references here because local file can be reference too.
                    // I hope this is the only case, when FileResource can be a reference ;)
                    if (reference.getLocalResource() instanceof FileResource) {
                        FileResource file = (FileResource) reference.getLocalResource();
                        if (file.isReference()) {
                            result.put(file.getName(),
                                    fileResourceReferenceConverter.toClient(new ResourceReference(file.getReferenceURI()), options));
                        } else {
                            result.put(file.getName(), fileResourceReferenceConverter.toClient(new ResourceReference(file), options));
                        }
                    } else {
                        throw new IllegalStateException("ReportUnit can't contain references of type " +
                                reference.getLocalResource());
                    }
                } else {
                    result.put(getResourceNameForReference(reference), fileResourceReferenceConverter.toClient(reference, options));
                }
            }
        }
        return result;
    }

}