001 // License: GPL. For details, see LICENSE file.
002 package org.openstreetmap.josm.data.osm.event;
003
004 import java.util.ArrayList;
005 import java.util.Collection;
006 import java.util.Collections;
007 import java.util.List;
008
009 import org.openstreetmap.josm.data.osm.DataSet;
010 import org.openstreetmap.josm.data.osm.OsmPrimitive;
011
012 public class PrimitivesAddedEvent extends AbstractDatasetChangedEvent {
013
014 private final List<? extends OsmPrimitive> primitives;
015 private final boolean wasIncomplete;
016
017 public PrimitivesAddedEvent(DataSet dataSet, Collection<? extends OsmPrimitive> primitives, boolean wasIncomplete) {
018 super(dataSet);
019 this.primitives = Collections.unmodifiableList(new ArrayList<OsmPrimitive>(primitives));
020 this.wasIncomplete = wasIncomplete;
021 }
022
023 @Override
024 public void fire(DataSetListener listener) {
025 listener.primitivesAdded(this);
026 }
027
028 @Override
029 public List<? extends OsmPrimitive> getPrimitives() {
030 return primitives;
031 }
032
033 /**
034 *
035 * @return True if primitive was in dataset before (so it's not really added), but it was incomplete
036 */
037 public boolean wasIncomplete() {
038 return wasIncomplete;
039 }
040
041 @Override
042 public DatasetEventType getType() {
043 return DatasetEventType.PRIMITIVES_ADDED;
044 }
045
046 }