Source:
private DownloadBatch getDownloadBatch(FileOperations fileOperations, DownloadsBatchPersisted batchPersisted) { DownloadBatchStatus.Status status = batchPersisted.downloadBatchStatus(); DownloadBatchId downloadBatchId = batchPersisted.downloadBatchId(); DownloadBatchTitle downloadBatchTitle = batchPersisted.downloadBatchTitle(); long downloadedDateTimeInMillis = batchPersisted.downloadedDateTimeInMillis(); boolean notificationSeen = batchPersisted.notificationSeen(); List<DownloadFile> downloadFiles = downloadsFilePersistence.loadSync( downloadBatchId, status, fileOperations, downloadsFilePersistence ); downloadFiles = Collections.unmodifiableList(downloadFiles); Map<DownloadFileId, Long> downloadedFileSizeMap = new HashMap<>(downloadFiles.size()); long currentBytesDownloaded = 0; long totalBatchSizeBytes = 0; for (DownloadFile downloadFile : downloadFiles) { downloadedFileSizeMap.put(downloadFile.id(), downloadFile.getCurrentDownloadedBytes()); currentBytesDownloaded += downloadFile.getCurrentDownloadedBytes(); long totalFileSize = downloadFile.getTotalSize(); if (totalFileSize == 0) { totalBatchSizeBytes = 0; currentBytesDownloaded = 0; break; } else { totalBatchSizeBytes += totalFileSize; } } InternalDownloadBatchStatus liteDownloadBatchStatus = new LiteDownloadBatchStatus( downloadBatchId, downloadBatchTitle, downloadedDateTimeInMillis, currentBytesDownloaded, totalBatchSizeBytes, status, notificationSeen, DOWNLOAD_ERROR ); liteDownloadBatchStatus.update(currentBytesDownloaded, totalBatchSizeBytes); CallbackThrottle callbackThrottle = callbackThrottleCreator.create(); return new DownloadBatch( liteDownloadBatchStatus, downloadFiles, downloadedFileSizeMap, DownloadsBatchPersistence.this, callbackThrottle, connectionChecker ); }

Target:
private DownloadBatch getDownloadBatch(FileOperations fileOperations, DownloadsBatchPersisted batchPersisted) { DownloadBatchStatus.Status status = batchPersisted.downloadBatchStatus(); DownloadBatchId downloadBatchId = batchPersisted.downloadBatchId(); DownloadBatchTitle downloadBatchTitle = batchPersisted.downloadBatchTitle(); long downloadedDateTimeInMillis = batchPersisted.downloadedDateTimeInMillis(); boolean notificationSeen = batchPersisted.notificationSeen(); List<DownloadFile> downloadFiles = downloadsFilePersistence.loadSync( downloadBatchId, status, fileOperations, downloadsFilePersistence ); downloadFiles = Collections.unmodifiableList(downloadFiles); Map<DownloadFileId, Long> downloadedFileSizeMap = new HashMap<>(downloadFiles.size()); long currentBytesDownloaded = 0; long totalBatchSizeBytes = 0; for (DownloadFile downloadFile : downloadFiles) { downloadedFileSizeMap.put(downloadFile.id(), downloadFile.getCurrentDownloadedBytes()); currentBytesDownloaded += downloadFile.getCurrentDownloadedBytes(); long totalFileSize = downloadFile.getTotalSize(); if (totalFileSize == 0) { totalBatchSizeBytes = 0; currentBytesDownloaded = 0; break; } else { totalBatchSizeBytes += totalFileSize; } } InternalDownloadBatchStatus liteDownloadBatchStatus = new LiteDownloadBatchStatus( downloadBatchId, downloadBatchTitle, downloadedDateTimeInMillis, currentBytesDownloaded, totalBatchSizeBytes, status, notificationSeen, NO_DOWNLOAD_ERROR ); CallbackThrottle callbackThrottle = callbackThrottleCreator.create(); return new DownloadBatch( liteDownloadBatchStatus, downloadFiles, downloadedFileSizeMap, DownloadsBatchPersistence.this, callbackThrottle, connectionChecker ); }