001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.plugins.eventbus.gui.layer;
003
004import java.util.EventObject;
005import java.util.Objects;
006
007import org.openstreetmap.josm.gui.layer.OsmDataLayer;
008
009/**
010 * Event fired when the "upload discouraged" (upload=no) state changes.
011 */
012public class LayerStateChangeEvent extends EventObject {
013
014    private static final long serialVersionUID = 1L;
015
016    private final OsmDataLayer osmDataLayer;
017    private final boolean newValue;
018
019    /**
020     * Constructs a new {@code LayerStateChangeEvent}.
021     * @param source object on which the Event initially occurred
022     * @param layer data layer
023     * @param newValue new value of the "upload discouraged" (upload=no) state
024     */
025    public LayerStateChangeEvent(Object source, OsmDataLayer layer, boolean newValue) {
026        super(source);
027        this.osmDataLayer = Objects.requireNonNull(layer);
028        this.newValue = newValue;
029    }
030
031    /**
032     * Returns the data layer.
033     * @return the data layer
034     */
035    public final OsmDataLayer getDataLayer() {
036        return osmDataLayer;
037    }
038
039    /**
040     * Returns the "upload discouraged" (upload=no) state.
041     * @return the "upload discouraged" (upload=no) state
042     */
043    public final boolean isUploadDiscouraged() {
044        return newValue;
045    }
046}