Changeset 11878 in josm for trunk/src/org/openstreetmap/josm/data/osm/history/HistoryOsmPrimitive.java
- Timestamp:
- 2017-04-10T00:14:42+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryOsmPrimitive.java
r11608 r11878 13 13 import java.util.Objects; 14 14 15 import org.openstreetmap.josm.Main; 15 16 import org.openstreetmap.josm.data.osm.Changeset; 16 17 import org.openstreetmap.josm.data.osm.Node; 17 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; 18 19 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 20 import org.openstreetmap.josm.data.osm.PrimitiveData; 19 21 import org.openstreetmap.josm.data.osm.PrimitiveId; 20 22 import org.openstreetmap.josm.data.osm.Relation; … … 24 26 import org.openstreetmap.josm.data.osm.Way; 25 27 import org.openstreetmap.josm.tools.CheckParameterUtil; 28 import org.openstreetmap.josm.tools.date.DateUtils; 26 29 27 30 /** … … 85 88 this.user = user; 86 89 this.changesetId = changesetId; 87 this.timestamp = timestamp;88 t ags = new HashMap<>();90 this.timestamp = DateUtils.cloneDate(timestamp); 91 this.tags = new HashMap<>(); 89 92 } 90 93 … … 159 162 */ 160 163 public Date getTimestamp() { 161 return timestamp;164 return DateUtils.cloneDate(timestamp); 162 165 } 163 166 … … 170 173 } 171 174 175 /** 176 * Checks that value is positive. 177 * @param value value to check 178 * @param name parameter name for error message 179 * @throws IllegalArgumentException if {@code value <= 0} 180 */ 172 181 protected final void ensurePositiveLong(long value, String name) { 173 182 if (value <= 0) { … … 176 185 } 177 186 187 /** 188 * Determines if this history matches given id and version. 189 * @param id Primitive identifier 190 * @param version Primitive version 191 * @return {@code true} if this history matches given id and version 192 */ 178 193 public boolean matches(long id, long version) { 179 194 return this.id == id && this.version == version; 180 195 } 181 196 197 /** 198 * Determines if this history matches given id. 199 * @param id Primitive identifier 200 * @return {@code true} if this history matches given id 201 */ 182 202 public boolean matches(long id) { 183 203 return this.id == id; … … 325 345 } 326 346 347 /** 348 * Fills the attributes common to all primitives with values from this history. 349 * @param data primitive data to fill 350 */ 351 protected void fillPrimitiveCommonData(PrimitiveData data) { 352 data.setUser(user); 353 try { 354 data.setVisible(visible); 355 } catch (IllegalStateException e) { 356 Main.error(e, "Cannot change visibility for "+data+':'); 357 } 358 data.setTimestamp(timestamp); 359 data.setKeys(tags); 360 data.setOsmId(id, (int) version); 361 } 362 327 363 @Override 328 364 public int hashCode() { … … 335 371 if (obj == null || getClass() != obj.getClass()) return false; 336 372 HistoryOsmPrimitive that = (HistoryOsmPrimitive) obj; 337 return id == that.id && 338 version == that.version; 373 return id == that.id && version == that.version; 339 374 } 340 375
Note:
See TracChangeset
for help on using the changeset viewer.