1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.osm;
|
---|
3 |
|
---|
4 | import java.util.Collection;
|
---|
5 | import java.util.Map;
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * Objects implement Tagged if they provide a map of key/value pairs.
|
---|
9 | *
|
---|
10 | * @since 2115
|
---|
11 | */
|
---|
12 | // FIXME: better naming? setTags(), getTags(), getKeys() instead of keySet() ?
|
---|
13 | //
|
---|
14 | public interface Tagged {
|
---|
15 | /**
|
---|
16 | * Sets the map of key/value pairs
|
---|
17 | *
|
---|
18 | * @param keys the map of key value pairs. If null, reset to the empty map.
|
---|
19 | */
|
---|
20 | void setKeys(Map<String, String> keys);
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Replies the map of key/value pairs. Never null, but may be the empty map.
|
---|
24 | *
|
---|
25 | * @return the map of key/value pairs
|
---|
26 | */
|
---|
27 | Map<String, String> getKeys();
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Sets a key/value pairs
|
---|
31 | *
|
---|
32 | * @param key the key
|
---|
33 | * @param value the value. If null, removes the key/value pair.
|
---|
34 | */
|
---|
35 | void put(String key, String value);
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * Sets a key/value pairs
|
---|
39 | *
|
---|
40 | * @param tag The tag to set.
|
---|
41 | * @since 10736
|
---|
42 | */
|
---|
43 | default void put(Tag tag) {
|
---|
44 | put(tag.getKey(), tag.getValue());
|
---|
45 | }
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Replies the value of the given key; null, if there is no value for this key
|
---|
49 | *
|
---|
50 | * @param key the key
|
---|
51 | * @return the value
|
---|
52 | */
|
---|
53 | String get(String key);
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * Removes a given key/value pair
|
---|
57 | *
|
---|
58 | * @param key the key
|
---|
59 | */
|
---|
60 | void remove(String key);
|
---|
61 |
|
---|
62 | /**
|
---|
63 | * Replies true, if there is at least one key/value pair; false, otherwise
|
---|
64 | *
|
---|
65 | * @return true, if there is at least one key/value pair; false, otherwise
|
---|
66 | */
|
---|
67 | boolean hasKeys();
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * Replies true if there is a tag with key <code>key</code>.
|
---|
71 | *
|
---|
72 | * @param key the key
|
---|
73 | * @return true, if there is a tag with key <code>key</code>
|
---|
74 | * @since 11608
|
---|
75 | */
|
---|
76 | default boolean hasKey(String key) {
|
---|
77 | return get(key) != null;
|
---|
78 | }
|
---|
79 |
|
---|
80 | /**
|
---|
81 | * Replies the set of keys
|
---|
82 | *
|
---|
83 | * @return the set of keys
|
---|
84 | */
|
---|
85 | Collection<String> keySet();
|
---|
86 |
|
---|
87 | /**
|
---|
88 | * Removes all tags
|
---|
89 | */
|
---|
90 | void removeAll();
|
---|
91 | }
|
---|