source: josm/trunk/src/org/openstreetmap/josm/data/osm/event/AbstractDatasetChangedEvent.java@ 12189

Last change on this file since 12189 was 12189, checked in by michael2402, 7 years ago

See #14794: Javadoc for data.osm package

  • Property svn:eol-style set to native
File size: 2.9 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm.event;
3
4import java.util.Collection;
5
6import org.openstreetmap.josm.data.osm.DataSet;
7import org.openstreetmap.josm.data.osm.OsmPrimitive;
8
9/**
10 * Base class of all dataset change events.
11 * @since 2622
12 */
13public abstract class AbstractDatasetChangedEvent {
14
15 /**
16 * Type of dataset changed event, returned by {@link AbstractDatasetChangedEvent#getType}.
17 */
18 public enum DatasetEventType {
19 /**
20 * A combination of multiple events
21 */
22 DATA_CHANGED,
23 /**
24 * The lat/lon coordinates of a node have changed.
25 */
26 NODE_MOVED,
27 /**
28 * Primitives have been added to this dataset
29 */
30 PRIMITIVES_ADDED,
31 /**
32 * Primitives have been removed from this dataset
33 */
34 PRIMITIVES_REMOVED,
35 /**
36 * The members of a relation have changed
37 */
38 RELATION_MEMBERS_CHANGED,
39 /**
40 * The tags of a primitve have changed
41 */
42 TAGS_CHANGED,
43 /**
44 * The nodes of a way or their order has changed
45 */
46 WAY_NODES_CHANGED,
47 /**
48 * The changeset id changed for a list of primitives
49 */
50 CHANGESET_ID_CHANGED,
51 /**
52 * The flags changed for a primitive and have not been covered in an other event
53 */
54 PRIMITIVE_FLAGS_CHANGED,
55 }
56
57 /**
58 * The dataset from which the event came from.
59 */
60 protected final DataSet dataSet;
61
62 /**
63 * Constructs a new {@code AbstractDatasetChangedEvent}.
64 * @param dataSet the dataset from which the event came from
65 */
66 protected AbstractDatasetChangedEvent(DataSet dataSet) {
67 this.dataSet = dataSet;
68 }
69
70 /**
71 * Calls the appropriate method of the listener for this event.
72 * @param listener dataset listener to notify about this event
73 */
74 public abstract void fire(DataSetListener listener);
75
76 /**
77 * Returns list of primitives modified by this event.
78 * <br>
79 * <strong>WARNING</strong> This value might be incorrect in case
80 * of {@link DataChangedEvent}. It returns all primitives in the dataset
81 * when this method is called (live list), not list of primitives when
82 * the event was created
83 * @return List of modified primitives
84 */
85 public abstract Collection<? extends OsmPrimitive> getPrimitives();
86
87 /**
88 * Returns the dataset from which the event came from.
89 * @return the dataset from which the event came from
90 */
91 public DataSet getDataset() {
92 return dataSet;
93 }
94
95 /**
96 * Returns the type of dataset changed event.
97 * @return the type of dataset changed event
98 */
99 public abstract DatasetEventType getType();
100
101 @Override
102 public String toString() {
103 return getType().toString();
104 }
105
106}
Note: See TracBrowser for help on using the repository browser.