Changeset 11928 in josm


Ignore:
Timestamp:
2017-04-16T14:42:27+02:00 (9 days ago)
Author:
Don-vip
Message:

improve unit tests, javadoc

Location:
trunk
Files:
10 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/event/AbstractDatasetChangedEvent.java

    r9941 r11928  
    77import org.openstreetmap.josm.data.osm.OsmPrimitive;
    88
     9/**
     10 * Base class of all dataset change events.
     11 * @since 2622
     12 */
    913public abstract class AbstractDatasetChangedEvent {
    1014
     15    /**
     16     * Type of dataset changed event, returned by {@link AbstractDatasetChangedEvent#getType}.
     17     */
    1118    public enum DatasetEventType {
    1219        DATA_CHANGED,
     
    2128    }
    2229
     30    /**
     31     * The dataset from which the event came from.
     32     */
    2333    protected final DataSet dataSet;
    2434
     35    /**
     36     * Constructs a new {@code AbstractDatasetChangedEvent}.
     37     * @param dataSet the dataset from which the event came from
     38     */
    2539    protected AbstractDatasetChangedEvent(DataSet dataSet) {
    2640        this.dataSet = dataSet;
    2741    }
    2842
     43    /**
     44     * Calls the appropriate method of the listener for this event.
     45     * @param listener dataset listener to notify about this event
     46     */
    2947    public abstract void fire(DataSetListener listener);
    3048
     
    4058    public abstract Collection<? extends OsmPrimitive> getPrimitives();
    4159
     60    /**
     61     * Returns the dataset from which the event came from.
     62     * @return the dataset from which the event came from
     63     */
    4264    public DataSet getDataset() {
    4365        return dataSet;
    4466    }
    4567
     68    /**
     69     * Returns the type of dataset changed event.
     70     * @return the type of dataset changed event
     71     */
    4672    public abstract DatasetEventType getType();
    4773
  • trunk/src/org/openstreetmap/josm/data/osm/event/ChangesetIdChangedEvent.java

    r5170 r11928  
    1313    private final int newChangesetId;
    1414
     15    /**
     16     * Constructs a new {@code ChangesetIdChangedEvent}.
     17     * @param dataSet the dataset from which the event comes from
     18     * @param primitives list of affected primitives
     19     * @param oldChangesetId old changeset id
     20     * @param newChangesetId new changeset id
     21     */
    1522    public ChangesetIdChangedEvent(DataSet dataSet, List<OsmPrimitive> primitives, int oldChangesetId, int newChangesetId) {
    1623        super(dataSet);
     
    3542    }
    3643
     44    /**
     45     * Returns the old changeset id.
     46     * @return the old changeset id
     47     */
    3748    public int getOldChangesetId() {
    3849        return oldChangesetId;
    3950    }
    4051
     52    /**
     53     * Returns the new changeset id.
     54     * @return the new changeset id
     55     */
    4156    public int getNewChangesetId() {
    4257        return newChangesetId;
  • trunk/src/org/openstreetmap/josm/data/osm/event/DataChangedEvent.java

    r11553 r11928  
    1515    /**
    1616     * Constructs a new {@code DataChangedEvent}
    17      * @param dataSet data set
     17     * @param dataSet the dataset from which the event comes from
    1818     * @param events list of change events
    1919     */
     
    2525    /**
    2626     * Constructs a new {@code DataChangedEvent}
    27      * @param dataSet data set
     27     * @param dataSet data set. Can be null
    2828     */
    2929    public DataChangedEvent(DataSet dataSet) {
  • trunk/src/org/openstreetmap/josm/data/osm/event/DataSetListenerAdapter.java

    r10600 r11928  
    44/**
    55 * Classes that do not wish to implement all methods of DataSetListener
    6  * may use this class. Implement DatasetListenerAdapter.Listener and
     6 * may use this class. Implement {@link DataSetListenerAdapter.Listener} and
    77 * pass this adapter instead of class itself.
    8  *
     8 * @since 2622
    99 */
    1010public class DataSetListenerAdapter implements DataSetListener {
    1111
     12    /**
     13     * Single method dataset change event listener.
     14     */
    1215    @FunctionalInterface
    1316    public interface Listener {
     17        /**
     18         * Called when notified about any type of dataset change event.
     19         * @param event dataset change event
     20         */
    1421        void processDatasetEvent(AbstractDatasetChangedEvent event);
    1522    }
     
    1724    private final Listener listener;
    1825
     26    /**
     27     * Constructs a new {@code DataSetListenerAdapter}.
     28     * @param listener listener for which its {@code processDatasetEvent()} method will be called for all events
     29     */
    1930    public DataSetListenerAdapter(Listener listener) {
    2031        this.listener = listener;
  • trunk/src/org/openstreetmap/josm/data/osm/event/DatasetEventManager.java

    r11796 r11928  
    9393    }
    9494
     95    /**
     96     * Event firing mode regarding Event Dispatch Thread.
     97     */
    9598    public enum FireMode {
    9699        /**
     
    167170    }
    168171
     172    /**
     173     * Unregister listener.
     174     * @param listener listener to remove
     175     */
    169176    public void removeDatasetListener(DataSetListener listener) {
    170177        ListenerInfo searchListener = new ListenerInfo(listener, false);
  • trunk/src/org/openstreetmap/josm/data/osm/event/NodeMovedEvent.java

    r5170 r11928  
    1313    private final Node node;
    1414
     15    /**
     16     * Constructs a new {@code NodeMovedEvent}.
     17     * @param dataSet the dataset from which the event comes from
     18     * @param node the node affected by the move
     19     */
    1520    public NodeMovedEvent(DataSet dataSet, Node node) {
    1621        super(dataSet);
     
    2328    }
    2429
     30    /**
     31     * Returns the node affected by the move.
     32     * @return the node affected by the move
     33     */
    2534    public Node getNode() {
    2635        return node;
     
    3645        return DatasetEventType.NODE_MOVED;
    3746    }
    38 
    3947}
  • trunk/src/org/openstreetmap/josm/data/osm/event/PrimitiveFlagsChangedEvent.java

    r9941 r11928  
    1515    private final OsmPrimitive primitive;
    1616
     17    /**
     18     * Constructs a new {@code PrimitiveFlagsChangedEvent}.
     19     * @param dataSet the dataset from which the event comes from
     20     * @param primitive the primitive affected by the change
     21     */
    1722    public PrimitiveFlagsChangedEvent(DataSet dataSet, OsmPrimitive primitive) {
    1823        super(dataSet);
  • trunk/src/org/openstreetmap/josm/data/osm/event/PrimitivesAddedEvent.java

    r7005 r11928  
    1515    private final boolean wasIncomplete;
    1616
     17    /**
     18     * Constructs a new {@code PrimitivesAddedEvent}.
     19     * @param dataSet the dataset from which the event comes from
     20     * @param primitives the list of primitives affected by the change
     21     * @param wasIncomplete {@code true} if primitive was in dataset before (so it's not really added), but it was incomplete
     22     */
    1723    public PrimitivesAddedEvent(DataSet dataSet, Collection<? extends OsmPrimitive> primitives, boolean wasIncomplete) {
    1824        super(dataSet);
     
    3238
    3339    /**
    34      *
    35      * @return True if primitive was in dataset before (so it's not really added), but it was incomplete
     40     * Determines if primitive was in dataset before (so it's not really added), but it was incomplete
     41     * @return {@code true} if primitive was in dataset before (so it's not really added), but it was incomplete
    3642     */
    3743    public boolean wasIncomplete() {
  • trunk/src/org/openstreetmap/josm/data/osm/event/PrimitivesRemovedEvent.java

    r7005 r11928  
    1515    private final boolean wasComplete;
    1616
     17    /**
     18     * Constructs a new {@code PrimitivesRemovedEvent}.
     19     * @param dataSet the dataset from which the event comes from
     20     * @param primitives the list of primitives affected by the change
     21     * @param wasComplete {@code true} if primitive wasn't really removed from the dataset, it only become incomplete again
     22     */
    1723    public PrimitivesRemovedEvent(DataSet dataSet, Collection<? extends OsmPrimitive> primitives, boolean wasComplete) {
    1824        super(dataSet);
     
    3238
    3339    /**
    34      *
    35      * @return True if primitive wasn't really removed from the dataset, it only become incomplete again
     40     * Determines if primitive wasn't really removed from the dataset, it only become incomplete again.
     41     * @return {@code true} if primitive wasn't really removed from the dataset, it only become incomplete again
    3642     */
    3743    public boolean wasComplete() {
  • trunk/src/org/openstreetmap/josm/data/osm/event/RelationMembersChangedEvent.java

    r5170 r11928  
    1313    private final Relation relation;
    1414
     15    /**
     16     * Constructs a new {@code RelationMembersChangedEvent}.
     17     * @param dataSet the dataset from which the event comes from
     18     * @param relation the relation affected by the change
     19     */
    1520    public RelationMembersChangedEvent(DataSet dataSet, Relation relation) {
    1621        super(dataSet);
     
    2328    }
    2429
     30    /**
     31     * Returns the relation affected by the change.
     32     * @return the relation affected by the change
     33     */
    2534    public Relation getRelation() {
    2635        return relation;
  • trunk/src/org/openstreetmap/josm/data/osm/event/SelectionEventManager.java

    r10608 r11928  
    1717 * Similar like {@link DatasetEventManager}, just for selection events. Because currently selection changed
    1818 * event are global, only FIRE_IN_EDT and FIRE_EDT_CONSOLIDATED modes are really useful
    19  *
     19 * @since 2912
    2020 */
    2121public class SelectionEventManager implements SelectionChangedListener {
     
    2323    private static final SelectionEventManager instance = new SelectionEventManager();
    2424
     25    /**
     26     * Returns the unique instance.
     27     * @return the unique instance
     28     */
    2529    public static SelectionEventManager getInstance() {
    2630        return instance;
     
    5963    }
    6064
     65    /**
     66     * Registers a new {@code SelectionChangedListener}.
     67     * @param listener listener to add
     68     * @param fireMode EDT firing mode
     69     */
    6170    public void addSelectionListener(SelectionChangedListener listener, FireMode fireMode) {
    6271        if (fireMode == FireMode.IN_EDT)
     
    6978    }
    7079
     80    /**
     81     * Unregisters a {@code SelectionChangedListener}.
     82     * @param listener listener to remove
     83     */
    7184    public void removeSelectionListener(SelectionChangedListener listener) {
    7285        ListenerInfo searchListener = new ListenerInfo(listener);
  • trunk/src/org/openstreetmap/josm/data/osm/event/TagsChangedEvent.java

    r5170 r11928  
    1414    private final Map<String, String> originalKeys;
    1515
     16    /**
     17     * Constructs a new {@code TagsChangedEvent}.
     18     * @param dataSet the dataset from which the event comes from
     19     * @param primitive the primitive affected by the change
     20     * @param originalKeys the original tags
     21     */
    1622    public TagsChangedEvent(DataSet dataSet, OsmPrimitive primitive, Map<String, String> originalKeys) {
    1723        super(dataSet);
     
    2531    }
    2632
     33    /**
     34     * Returns the primitive affected by the change.
     35     * @return the primitive affected by the change
     36     */
    2737    public OsmPrimitive getPrimitive() {
    2838        return primitive;
     
    3949    }
    4050
     51    /**
     52     * Returns the original tags.
     53     * @return the original tags
     54     */
    4155    public Map<String, String> getOriginalKeys() {
    4256        return originalKeys;
  • trunk/src/org/openstreetmap/josm/data/osm/event/WayNodesChangedEvent.java

    r5170 r11928  
    1313    private final Way way;
    1414
     15    /**
     16     * Constructs a new {@code WayNodesChangedEvent}.
     17     * @param dataSet the dataset from which the event comes from
     18     * @param way the way affected by the change
     19     */
    1520    public WayNodesChangedEvent(DataSet dataSet, Way way) {
    1621        super(dataSet);
     
    2328    }
    2429
     30    /**
     31     * Returns the way affected by the change.
     32     * @return the way affected by the change
     33     */
    2534    public Way getChangedWay() {
    2635        return way;
Note: See TracChangeset for help on using the changeset viewer.