@@ -0,0 +1,2236 @@
+package com.novoda.downloadmanager;%0A%0Aimport android.support.annotation.WorkerThread;%0A%0Aclass NotificationDispatcher%3CT%3E %7B%0A%0A    private final Object waitForDownloadService;%0A    private final NotificationCreator%3CT%3E notificationCreator;%0A%0A    private DownloadService downloadService;%0A%0A    NotificationDispatcher(Object waitForDownloadService,%0A                           NotificationCreator%3CT%3E notificationCreator) %7B%0A        this.waitForDownloadService = waitForDownloadService;%0A        this.notificationCreator = notificationCreator;%0A    %7D%0A%0A    @WorkerThread%0A    void updateNotification(T payload) %7B%0A        WaitForDownloadService.%3CVoid%3EwaitFor(downloadService, waitForDownloadService)%0A                .thenPerform(executeUpdateNotification(payload));%0A    %7D%0A%0A    private WaitForDownloadService.ThenPerform.Action%3CVoid%3E executeUpdateNotification(T downloadBatchStatus) %7B%0A        return () -%3E %7B%0A            NotificationInformation notificationInformation = notificationCreator.createNotification(downloadBatchStatus);%0A%0A            downloadService.dismissStackedNotification(notificationInformation);%0A%0A            switch (notificationInformation.notificationStackState()) %7B%0A                case SINGLE_PERSISTENT_NOTIFICATION:%0A                    downloadService.updateNotification(notificationInformation);%0A                    break;%0A                case STACK_NOTIFICATION_NOT_DISMISSIBLE:%0A                    downloadService.stackNotificationNotDismissible(notificationInformation);%0A                    break;%0A                case STACK_NOTIFICATION_DISMISSIBLE:%0A                    downloadService.stackNotification(notificationInformation);%0A                    break;%0A                default:%0A                    String message = String.format(%0A                            %22%25s: %25s is not supported.%22,%0A                            NotificationCustomizer.NotificationStackState.class.getSimpleName(),%0A                            notificationInformation.notificationStackState()%0A                    );%0A                    throw new IllegalArgumentException(message);%0A            %7D%0A%0A            return null;%0A        %7D;%0A    %7D%0A%0A    void setDownloadService(DownloadService downloadService) %7B%0A        this.downloadService = downloadService;%0A    %7D%0A%7D%0A

Create a generic NotificationDispatcher that can work on multiple payloads.