source: josm/trunk/src/org/openstreetmap/josm/data/osm/PrimitiveData.java@ 7501

Last change on this file since 7501 was 7005, checked in by Don-vip, 10 years ago

see #8465 - use diamond operator where applicable

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm;
3
4import java.util.ArrayList;
5import java.util.Arrays;
6import java.util.Collection;
7import java.util.List;
8import java.util.Map;
9
10/**
11 * This class can be used to save properties of OsmPrimitive.
12 *
13 * The main difference between PrimitiveData
14 * and OsmPrimitive is that PrimitiveData is not part of the dataset and changes in PrimitiveData are not
15 * reported by events
16 */
17public abstract class PrimitiveData extends AbstractPrimitive {
18
19 /**
20 * Constructs a new {@code PrimitiveData}.
21 */
22 public PrimitiveData() {
23 id = OsmPrimitive.generateUniqueId();
24 }
25
26 public PrimitiveData(PrimitiveData data) {
27 cloneFrom(data);
28 }
29
30 public void setId(long id) {
31 this.id = id;
32 }
33
34 public void setVersion(int version) {
35 this.version = version;
36 }
37
38 /**
39 * override to make it public
40 */
41 @Override
42 public void setIncomplete(boolean incomplete) {
43 super.setIncomplete(incomplete);
44 }
45
46 public abstract PrimitiveData makeCopy();
47
48 @Override
49 public String toString() {
50 StringBuilder builder = new StringBuilder();
51 builder.append(id).append(Arrays.toString(keys)).append(getFlagsAsString());
52 return builder.toString();
53 }
54
55 @SuppressWarnings("unchecked")
56 public static <T extends PrimitiveData> List<T> getFilteredList(Collection<T> list, OsmPrimitiveType type) {
57 List<T> ret = new ArrayList<>();
58 for(PrimitiveData p: list) {
59 if (type.getDataClass().isInstance(p)) {
60 ret.add((T)p);
61 }
62 }
63 return ret;
64 }
65
66 @Override
67 protected final void keysChangedImpl(Map<String, String> originalKeys) {
68 }
69
70 @Override
71 public abstract OsmPrimitiveType getType();
72}
Note: See TracBrowser for help on using the repository browser.