1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.osm.event;
|
---|
3 |
|
---|
4 | import java.util.Collections;
|
---|
5 | import java.util.List;
|
---|
6 | import java.util.Map;
|
---|
7 |
|
---|
8 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
9 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * An event that is triggered if the tags of a single primitive have changed
|
---|
13 | */
|
---|
14 | public class TagsChangedEvent extends AbstractDatasetChangedEvent {
|
---|
15 |
|
---|
16 | private final OsmPrimitive primitive;
|
---|
17 | private final Map<String, String> originalKeys;
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * Constructs a new {@code TagsChangedEvent}.
|
---|
21 | * @param dataSet the dataset from which the event comes from
|
---|
22 | * @param primitive the primitive affected by the change
|
---|
23 | * @param originalKeys the original tags
|
---|
24 | */
|
---|
25 | public TagsChangedEvent(DataSet dataSet, OsmPrimitive primitive, Map<String, String> originalKeys) {
|
---|
26 | super(dataSet);
|
---|
27 | this.primitive = primitive;
|
---|
28 | this.originalKeys = originalKeys;
|
---|
29 | }
|
---|
30 |
|
---|
31 | @Override
|
---|
32 | public void fire(DataSetListener listener) {
|
---|
33 | listener.tagsChanged(this);
|
---|
34 | }
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * Returns the primitive affected by the change.
|
---|
38 | * @return the primitive affected by the change
|
---|
39 | */
|
---|
40 | public OsmPrimitive getPrimitive() {
|
---|
41 | return primitive;
|
---|
42 | }
|
---|
43 |
|
---|
44 | @Override
|
---|
45 | public List<? extends OsmPrimitive> getPrimitives() {
|
---|
46 | return Collections.singletonList(primitive);
|
---|
47 | }
|
---|
48 |
|
---|
49 | @Override
|
---|
50 | public DatasetEventType getType() {
|
---|
51 | return DatasetEventType.TAGS_CHANGED;
|
---|
52 | }
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * Returns the original tags.
|
---|
56 | * @return the original tags
|
---|
57 | */
|
---|
58 | public Map<String, String> getOriginalKeys() {
|
---|
59 | return originalKeys;
|
---|
60 | }
|
---|
61 |
|
---|
62 | }
|
---|