source: josm/trunk/src/org/openstreetmap/josm/data/osm/event/DataChangedEvent.java@ 12116

Last change on this file since 12116 was 11928, checked in by Don-vip, 7 years ago

improve unit tests, javadoc

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm.event;
3
4import java.util.Collection;
5import java.util.Collections;
6import java.util.List;
7
8import org.openstreetmap.josm.data.osm.DataSet;
9import org.openstreetmap.josm.data.osm.OsmPrimitive;
10
11public class DataChangedEvent extends AbstractDatasetChangedEvent {
12
13 private final List<AbstractDatasetChangedEvent> events;
14
15 /**
16 * Constructs a new {@code DataChangedEvent}
17 * @param dataSet the dataset from which the event comes from
18 * @param events list of change events
19 */
20 public DataChangedEvent(DataSet dataSet, List<AbstractDatasetChangedEvent> events) {
21 super(dataSet);
22 this.events = events;
23 }
24
25 /**
26 * Constructs a new {@code DataChangedEvent}
27 * @param dataSet data set. Can be null
28 */
29 public DataChangedEvent(DataSet dataSet) {
30 this(dataSet, null);
31 }
32
33 @Override
34 public void fire(DataSetListener listener) {
35 listener.dataChanged(this);
36 }
37
38 @Override
39 public Collection<OsmPrimitive> getPrimitives() {
40 return dataSet == null ? Collections.emptyList() : dataSet.allPrimitives();
41 }
42
43 @Override
44 public DatasetEventType getType() {
45 return DatasetEventType.DATA_CHANGED;
46 }
47
48 /**
49 * Returns list of events that caused this DataChangedEvent.
50 * @return List of events that caused this DataChangedEvent. Might be null
51 */
52 public List<AbstractDatasetChangedEvent> getEvents() {
53 return events;
54 }
55}
Note: See TracBrowser for help on using the repository browser.