001/*
002 * #%L
003 * Netarchivesuite - harvester
004 * %%
005 * Copyright (C) 2005 - 2014 The Royal Danish Library, the Danish State and University Library,
006 *             the National Library of France and the Austrian National Library.
007 * %%
008 * This program is free software: you can redistribute it and/or modify
009 * it under the terms of the GNU Lesser General Public License as
010 * published by the Free Software Foundation, either version 2.1 of the
011 * License, or (at your option) any later version.
012 * 
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Lesser Public License for more details.
017 * 
018 * You should have received a copy of the GNU General Lesser Public
019 * License along with this program.  If not, see
020 * <http://www.gnu.org/licenses/lgpl-2.1.html>.
021 * #L%
022 */
023package dk.netarkivet.harvester.harvesting.distribute;
024
025import java.io.Serializable;
026
027import dk.netarkivet.common.exceptions.ArgumentNotValid;
028import dk.netarkivet.harvester.datamodel.StopReason;
029
030/** Tuple class to hold domain harvest statistics for a single domain. */
031
032@SuppressWarnings({"serial"})
033public class DomainStats implements Serializable {
034
035    /** Count of how many objects have been harvested from this domain. */
036    private long objectCount;
037    /** Count of how many bytes have been harvested from this domain . */
038    private long byteCount;
039    /**
040     * The reason why we 'only' harvested byteCount bytes or objectCount objects.
041     */
042    private StopReason stopReason;
043
044    /**
045     * Constructor for a DomainStats object.
046     *
047     * @param initObjectCount Start counting objects from this number
048     * @param initByteCount Start counting bytes from this number
049     * @param defaultStopReason The default StopReason for a given domain.
050     * @throws ArgumentNotValid If initObjectCount < 0, initByteCount < 0, or defaultStopReason is null.
051     */
052    public DomainStats(long initObjectCount, long initByteCount, StopReason defaultStopReason) {
053        ArgumentNotValid.checkNotNegative(initObjectCount, "initObjectCount");
054        ArgumentNotValid.checkNotNegative(initByteCount, "initByteCount");
055        ArgumentNotValid.checkNotNull(defaultStopReason, "defaultStopReason");
056        this.objectCount = initObjectCount;
057        this.byteCount = initByteCount;
058        this.stopReason = defaultStopReason;
059    }
060
061    /**
062     * @return the byteCount.
063     */
064    public long getByteCount() {
065        return byteCount;
066    }
067
068    /**
069     * @param byteCount The byteCount to set.
070     * @throws ArgumentNotValid If byteCount is a negative number.
071     */
072    public void setByteCount(long byteCount) {
073        ArgumentNotValid.checkNotNegative(byteCount, "byteCount");
074        this.byteCount = byteCount;
075    }
076
077    /**
078     * @return the objectCount.
079     */
080    public long getObjectCount() {
081        return objectCount;
082    }
083
084    /**
085     * Set objectcount to something new.
086     *
087     * @param objectCount The objectCount to set.
088     * @throws ArgumentNotValid If objectCount is a negative number.
089     */
090    public void setObjectCount(long objectCount) {
091        ArgumentNotValid.checkNotNegative(objectCount, "objectCount");
092        this.objectCount = objectCount;
093    }
094
095    /**
096     * @return the stopReason.
097     */
098    public StopReason getStopReason() {
099        return stopReason;
100    }
101
102    /**
103     * Set stopreason to something new.
104     *
105     * @param stopReason The stopReason to set.
106     * @throws ArgumentNotValid If argument is null
107     */
108    public void setStopReason(StopReason stopReason) {
109        ArgumentNotValid.checkNotNull(stopReason, "stopReason");
110        this.stopReason = stopReason;
111    }
112
113}