001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.io;
003
004import java.util.Objects;
005import java.util.Observable;
006
007/**
008 * ChangesetCommentModel is an observable model for the changeset comment edited
009 * in the {@link UploadDialog}.
010 * @since 3133
011 */
012public class ChangesetCommentModel extends Observable {
013    private String comment = "";
014
015    /**
016     * Sets the current changeset comment and notifies observers if the comment has changed.
017     *
018     * @param comment the new upload comment. Empty string assumed if null.
019     */
020    public void setComment(String comment) {
021        String oldValue = this.comment;
022        this.comment = comment == null ? "" : comment;
023        if (!Objects.equals(oldValue, this.comment)) {
024            setChanged();
025            notifyObservers(this.comment);
026        }
027    }
028
029    /**
030     * Replies the current changeset comment in this model.
031     *
032     * @return the current changeset comment in this model.
033     */
034    public String getComment() {
035        return comment == null ? "" : comment;
036    }
037}