Source:
<code>static DownloadBatch newInstance(Batch batch, FileOperations fileOperations, DownloadsBatchPersistence downloadsBatchPersistence, DownloadsFilePersistence downloadsFilePersistence, CallbackThrottle callbackThrottle) { DownloadBatchTitle downloadBatchTitle = DownloadBatchTitleCreator.createFrom(batch); Map<DownloadFileId, String> fileUrls = batch.getFileUrls(); List<DownloadFile> downloadFiles = new ArrayList<>(fileUrls.size()); DownloadBatchId downloadBatchId = batch.getDownloadBatchId(); for (Map.Entry<DownloadFileId, String> urlByDownloadId : fileUrls.entrySet()) { InternalFileSize fileSize = InternalFileSizeCreator.unknownFileSize(); FilePath filePath = FilePathCreator.unknownFilePath(); InternalDownloadFileStatus downloadFileStatus = new LiteDownloadFileStatus( batch.getDownloadBatchId(), urlByDownloadId.getKey(), InternalDownloadFileStatus.Status.QUEUED, fileSize, filePath ); <START> FileName fileName = LiteFileName.from(batch, urlByDownloadId.getValue()); <END> FilePersistenceCreator filePersistenceCreator = fileOperations.filePersistenceCreator(); FileDownloader fileDownloader = fileOperations.fileDownloader(); FileSizeRequester fileSizeRequester = fileOperations.fileSizeRequester(); FilePersistence filePersistence = filePersistenceCreator.create(); DownloadFile downloadFile = new DownloadFile( downloadBatchId, urlByDownloadId.getValue(), downloadFileStatus, fileName, filePath, fileSize, fileDownloader, fileSizeRequester, filePersistence, downloadsFilePersistence ); downloadFiles.add(downloadFile); } InternalDownloadBatchStatus liteDownloadBatchStatus = new LiteDownloadBatchStatus( downloadBatchId, downloadBatchTitle, DownloadBatchStatus.Status.QUEUED ); return new DownloadBatch( downloadBatchTitle, downloadBatchId, downloadFiles, new HashMap<>(), liteDownloadBatchStatus, downloadsBatchPersistence, callbackThrottle ); }</code><technical_language>extract urlByDownloadId.getValue() a fileUrl reuse in new DownloadFile</technical_language>

Target:
static DownloadBatch newInstance(Batch batch, FileOperations fileOperations, DownloadsBatchPersistence downloadsBatchPersistence, DownloadsFilePersistence downloadsFilePersistence, CallbackThrottle callbackThrottle) { DownloadBatchTitle downloadBatchTitle = DownloadBatchTitleCreator.createFrom(batch); Map<DownloadFileId, String> fileUrls = batch.getFileUrls(); List<DownloadFile> downloadFiles = new ArrayList<>(fileUrls.size()); DownloadBatchId downloadBatchId = batch.getDownloadBatchId(); for (Map.Entry<DownloadFileId, String> urlByDownloadId : fileUrls.entrySet()) { InternalFileSize fileSize = InternalFileSizeCreator.unknownFileSize(); FilePath filePath = FilePathCreator.unknownFilePath(); DownloadFileId downloadFileId = urlByDownloadId.getKey(); InternalDownloadFileStatus downloadFileStatus = new LiteDownloadFileStatus( downloadBatchId, downloadFileId, InternalDownloadFileStatus.Status.QUEUED, fileSize, filePath ); String fileUrl = urlByDownloadId.getValue(); FileName fileName = LiteFileName.from(batch, fileUrl); FilePersistenceCreator filePersistenceCreator = fileOperations.filePersistenceCreator(); FileDownloader fileDownloader = fileOperations.fileDownloader(); FileSizeRequester fileSizeRequester = fileOperations.fileSizeRequester(); FilePersistence filePersistence = filePersistenceCreator.create(); DownloadFile downloadFile = new DownloadFile( downloadBatchId, downloadFileId, fileUrl, downloadFileStatus, fileName, filePath, fileSize, fileDownloader, fileSizeRequester, filePersistence, downloadsFilePersistence ); downloadFiles.add(downloadFile); } InternalDownloadBatchStatus liteDownloadBatchStatus = new LiteDownloadBatchStatus( downloadBatchId, downloadBatchTitle, DownloadBatchStatus.Status.QUEUED ); return new DownloadBatch( downloadBatchTitle, downloadBatchId, downloadFiles, new HashMap<>(), liteDownloadBatchStatus, downloadsBatchPersistence, callbackThrottle ); }