package com.novoda.downloadmanager;

import android.support.annotation.Nullable;

import java.security.InvalidParameterException;

/**
 * Represents the information of a {@link DownloadBatch} that is accessible to clients.
 */
public interface DownloadBatchStatus {

    /**
     * The current download status for a whole batch.
     */
    enum Status {
        QUEUED,
        DOWNLOADING,
        PAUSED,
        ERROR,
        DELETING,
        DELETED,
        DOWNLOADED,
        WAITING_FOR_NETWORK,
        UNKNOWN;

        public String toRawValue() {
            return this.name();
        }

        public static Status from(String rawValue) {
            for (Status status : Status.values()) {
                if (status.name().equals(rawValue)) {
                    return status;
                }
            }

            throw new InvalidParameterException("Batch status " + rawValue + " not supported");
        }

    }

    /**
     * @return The title associated to a {@link DownloadBatch}.
     * Specified when calling {@link Batch#with(StorageRoot, DownloadBatchId, String)}.
     */
    DownloadBatchTitle getDownloadBatchTitle();

    /**
     * Returns the shared storage root for all download files in this batch.
     * The shared storage root for a downloaded file with storage location
     * `/data/user/0/com.novoda.downloadmanager.demo.simple/files/downloads/batch_id_2/20MB.zip`
     * would be `/data/user/0/com.novoda.downloadmanager.demo.simple/files/downloads`.
     *
     * @return The shared storage root.
     */
    String storageRoot();

    int percentageDownloaded();

    long bytesDownloaded();

    long bytesTotalSize();

    DownloadBatchId getDownloadBatchId();

    Status status();

    long downloadedDateTimeInMillis();

    /**
     * @return null if {@link DownloadBatchStatus#status()} is not {@link Status#ERROR}.
     */
    @Nullable
    DownloadError downloadError();

    boolean notificationSeen();
}

@@ -1590,158 +1590,780 @@
     
-int percentageDownloaded();%0A%0A    long bytesDownloaded();%0A%0A    long bytesTotalSize();%0A%0A    DownloadBatchId getDownloadBatchId();%0A%0A    Status status();%0A
+/**%0A     * @return The currently downloaded percentage of a %7B@link DownloadBatchStatus%7D.%0A     */%0A    int percentageDownloaded();%0A%0A    /**%0A     * @return The number of bytes that have been downloaded so far.%0A     */%0A    long bytesDownloaded();%0A%0A    /**%0A     * @return The total number of bytes to download.%0A     */%0A    long bytesTotalSize();%0A%0A    /**%0A     * @return The unique identifier for this batch.%0A     */%0A    DownloadBatchId getDownloadBatchId();%0A%0A    /**%0A     * @return The current %7B@link DownloadBatchStatus.Status%7D for the batch.%0A     */%0A    Status status();%0A%0A    /**%0A     * @return The time at which the batch started to download. Represented as the difference,%0A     * measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.%0A     */
 %0A   
@@ -2422,16 +2422,45 @@
 @return 
+The %7B@link DownloadError%7D or 
 null if 
@@ -2579,24 +2579,156 @@
 adError();%0A%0A
+    /**%0A     * @return whether the notification has been dispatched from %7B@link DownloadBatchStatusNotificationDispatcher%7D.%0A     */%0A
     boolean 

Add complete javadoc to DownloadBatchStatus.