001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.actions.downloadtasks;
003
004import org.openstreetmap.josm.data.osm.DownloadPolicy;
005import org.openstreetmap.josm.data.osm.UploadPolicy;
006
007/**
008 * Download parameters affecting the behaviour of {@link DownloadTask}s.
009 * @since 13927
010 */
011public class DownloadParams {
012
013    private boolean newLayer;
014    private String layerName;
015    private boolean locked;
016    private DownloadPolicy downloadPolicy;
017    private UploadPolicy uploadPolicy;
018
019    /**
020     * Determines if the data is to be downloaded into a new layer.
021     * @return true, if the data is to be downloaded into a new layer. If false, the task
022     * selects one of the existing layers as download layer, preferably the active layer.
023     * @see #getLayerName
024     */
025    public final boolean isNewLayer() {
026        return newLayer;
027    }
028
029    /**
030     * Sets whether the data is to be downloaded into a new layer.
031     * @param newLayer true, if the data is to be downloaded into a new layer. If false, the task
032     * selects one of the existing layers as download layer, preferably the active layer.
033     * @return this
034     * @see #withLayerName
035     */
036    public final DownloadParams withNewLayer(boolean newLayer) {
037        this.newLayer = newLayer;
038        return this;
039    }
040
041    /**
042     * Returns the new layer name (if a new layer is to be created).
043     * @return the new layer name, or null
044     * @see #isNewLayer
045     */
046    public final String getLayerName() {
047        return layerName;
048    }
049
050    /**
051     * Sets the new layer name (if a new layer is to be created).
052     * @param layerName the new layer name, or null
053     * @return this
054     * @see #withNewLayer
055     */
056    public final DownloadParams withLayerName(String layerName) {
057        this.layerName = layerName;
058        return this;
059    }
060
061    /**
062     * Determines if the new layer must be locked.
063     * @return {@code true} if the new layer must be locked
064     */
065    public final boolean isLocked() {
066        return locked;
067    }
068
069    /**
070     * Sets whether the new layer must be locked.
071     * @param locked {@code true} if the new layer must be locked
072     * @return this
073     */
074    public final DownloadParams withLocked(boolean locked) {
075        this.locked = locked;
076        return this;
077    }
078
079    /**
080     * Returns the download policy of new layer.
081     * @return the download policy of new layer
082     */
083    public final DownloadPolicy getDownloadPolicy() {
084        return downloadPolicy;
085    }
086
087    /**
088     * Sets the download policy of new layer.
089     * @param downloadPolicy the download policy of new layer
090     * @return this
091     */
092    public final DownloadParams withDownloadPolicy(DownloadPolicy downloadPolicy) {
093        this.downloadPolicy = downloadPolicy;
094        return this;
095    }
096
097    /**
098     * Returns the upload policy of new layer.
099     * @return the upload policy of new layer
100     */
101    public final UploadPolicy getUploadPolicy() {
102        return uploadPolicy;
103    }
104
105    /**
106     * Sets the upload policy of new layer.
107     * @param uploadPolicy the upload policy of new layer
108     * @return this
109     */
110    public final DownloadParams withUploadPolicy(UploadPolicy uploadPolicy) {
111        this.uploadPolicy = uploadPolicy;
112        return this;
113    }
114}