/*
 * Copyright 2017 huangjinfu
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package cn.hjf.downloader;

import java.io.Serializable;

/**
 * A class to present download progress of a task.
 *
 * @author huangjinfu
 */

public final class Progress implements Serializable {

    private static final long serialVersionUID = 1L;

    private final long total;
    private volatile long downloaded;

    public Progress(long total) {
        this.total = total;
    }

    public long getTotal() {
        return total;
    }

    public long getDownloaded() {
        return downloaded;
    }

    void setDownloaded(long downloaded) {
        this.downloaded = downloaded;
    }

    boolean finished() {
        return total == downloaded;
    }
}

@@ -848,354 +848,1309 @@
     
-private final long total;%0A    private volatile long downloaded;%0A%0A    public Progress(long total) %7B%0A        this.total = total;%0A    %7D%0A%0A    public long getTotal() %7B%0A        return total;%0A    %7D%0A%0A    public long getDownloaded() %7B%0A        return downloaded;%0A    %7D%0A%0A    void setDownloaded(long downloaded) %7B%0A        this.downloaded = downloaded;%0A    %7D%0A
+/**%0A     * Total size of resource, based on the byte unit.%0A     */%0A    private final long total;%0A    /**%0A     * Already downloaded size.%0A     */%0A    private volatile long downloaded;%0A    /**%0A     * Current estimate network speed, based on the kb/s unit.%0A     */%0A    private transient volatile double networkSpeed;%0A%0A    /**%0A     * Create new Progress instance.%0A     *%0A     * @param total Total size of this progress, total size can't be changed since Progress instance be constructed.%0A     */%0A    public Progress(long total) %7B%0A        this.total = total;%0A    %7D%0A%0A    /**%0A     * Get total size of this task.%0A     *%0A     * @return%0A     */%0A    public long getTotal() %7B%0A        return total;%0A    %7D%0A%0A    /**%0A     * Get already downloaded size of this task.%0A     *%0A     * @return%0A     */%0A    public long getDownloaded() %7B%0A        return downloaded;%0A    %7D%0A%0A    /**%0A     * Get estimate temporary network speed.%0A     *%0A     * @return%0A     */%0A    public double getNetworkSpeed() %7B%0A        return networkSpeed;%0A    %7D%0A%0A    void setDownloaded(long downloaded) %7B%0A        this.downloaded = downloaded;%0A    %7D%0A%0A    void setNetworkSpeed(double networkSpeed) %7B%0A        this.networkSpeed = networkSpeed;%0A    %7D%0A%0A    /**%0A     * Indicate that this Progress is finished.%0A     *%0A     * @return true if progress finished.%0A     */
 %0A   

Update Progress model.