1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.osm.event;
|
---|
3 |
|
---|
4 | import java.util.ArrayList;
|
---|
5 | import java.util.Collection;
|
---|
6 | import java.util.Collections;
|
---|
7 | import java.util.List;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
10 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
11 |
|
---|
12 | public class PrimitivesAddedEvent extends AbstractDatasetChangedEvent {
|
---|
13 |
|
---|
14 | private final List<? extends OsmPrimitive> primitives;
|
---|
15 | private final boolean wasIncomplete;
|
---|
16 |
|
---|
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 | */
|
---|
23 | public PrimitivesAddedEvent(DataSet dataSet, Collection<? extends OsmPrimitive> primitives, boolean wasIncomplete) {
|
---|
24 | super(dataSet);
|
---|
25 | this.primitives = Collections.unmodifiableList(new ArrayList<>(primitives));
|
---|
26 | this.wasIncomplete = wasIncomplete;
|
---|
27 | }
|
---|
28 |
|
---|
29 | @Override
|
---|
30 | public void fire(DataSetListener listener) {
|
---|
31 | listener.primitivesAdded(this);
|
---|
32 | }
|
---|
33 |
|
---|
34 | @Override
|
---|
35 | public List<? extends OsmPrimitive> getPrimitives() {
|
---|
36 | return primitives;
|
---|
37 | }
|
---|
38 |
|
---|
39 | /**
|
---|
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
|
---|
42 | */
|
---|
43 | public boolean wasIncomplete() {
|
---|
44 | return wasIncomplete;
|
---|
45 | }
|
---|
46 |
|
---|
47 | @Override
|
---|
48 | public DatasetEventType getType() {
|
---|
49 | return DatasetEventType.PRIMITIVES_ADDED;
|
---|
50 | }
|
---|
51 |
|
---|
52 | }
|
---|