001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.data.osm; 003 004import java.util.Collection; 005import java.util.Map; 006/** 007 * Objects implement Tagged if they provide a map of key/value pairs. 008 * 009 * 010 */ 011// FIXME: better naming? setTags(), getTags(), getKeys() instead of keySet() ? 012// 013public interface Tagged { 014 /** 015 * Sets the map of key/value pairs 016 * 017 * @param keys the map of key value pairs. If null, reset to the empty map. 018 */ 019 void setKeys(Map<String, String> keys); 020 021 /** 022 * Replies the map of key/value pairs. Never null, but may be the empty map. 023 * 024 * @return the map of key/value pairs 025 */ 026 Map<String, String> getKeys(); 027 028 /** 029 * Sets a key/value pairs 030 * 031 * @param key the key 032 * @param value the value. If null, removes the key/value pair. 033 */ 034 void put(String key, String value); 035 036 /** 037 * Sets a key/value pairs 038 * 039 * @param tag The tag to set. 040 * @since 10736 041 */ 042 default void put(Tag tag) { 043 put(tag.getKey(), tag.getValue()); 044 } 045 046 /** 047 * Replies the value of the given key; null, if there is no value for this key 048 * 049 * @param key the key 050 * @return the value 051 */ 052 String get(String key); 053 054 /** 055 * Removes a given key/value pair 056 * 057 * @param key the key 058 */ 059 void remove(String key); 060 061 /** 062 * Replies true, if there is at least one key/value pair; false, otherwise 063 * 064 * @return true, if there is at least one key/value pair; false, otherwise 065 */ 066 boolean hasKeys(); 067 068 /** 069 * Replies the set of keys 070 * 071 * @return the set of keys 072 */ 073 Collection<String> keySet(); 074 075 /** 076 * Removes all tags 077 */ 078 void removeAll(); 079}