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

Revision 5170, 1.8 KB checked in by Don-vip, 6 weeks ago (diff)

cleanup svn:mime-type properties preventing Java sources from being viewed as such on Trac

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