Interface Tagged

All Known Subinterfaces:
INode, IPrimitive, IRelation<M>, IWay<N>
All Known Implementing Classes:
AbstractPrimitive, Changeset, HistoryNode, HistoryOsmPrimitive, HistoryRelation, HistoryWay, Node, NodeData, OsmPrimitive, PrimitiveData, Relation, RelationData, Tag, VectorNode, VectorPrimitive, VectorRelation, VectorWay, Way, WayData

public interface Tagged
Objects implement Tagged if they provide a map of key/value pairs.
Since:
2115
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The maximum tag length allowed by OSM API
  • Method Summary

    Modifier and Type
    Method
    Description
    get(String key)
    Replies the value of the given key; null, if there is no value for this key
    Replies the map of key/value pairs.
    int
    Gets the number of keys
    default boolean
    Replies true if there is a tag with key key.
    boolean
    Replies true, if there is at least one key/value pair; false, otherwise
    default boolean
    Replies true if there is a non-empty tag with key key.
    default boolean
    hasTag(String key, String value)
    Tests whether this primitive contains a tag consisting of key and value.
    default boolean
    hasTag(String key, String... values)
    Tests whether this primitive contains a tag consisting of key and any of values.
    default boolean
    hasTag(String key, Collection<String> values)
    Tests whether this primitive contains a tag consisting of key and any of values.
    default boolean
    Tests whether this primitive contains a tag consisting of key and a value different from value.
    default boolean
    hasTagDifferent(String key, String... values)
    Tests whether this primitive contains a tag consisting of key and none of values.
    default boolean
    Tests whether this primitive contains a tag consisting of key and none of values.
    default boolean
    Returns true if the key corresponds to an OSM false value.
    default boolean
    Returns true if the key corresponds to an OSM true value.
    default Stream<String>
    Replies the keys as stream
    Replies the set of keys
    static Tagged
    Returns a Tagged instance for the given tag map
    static Tagged
    Returns a Tagged instance for the given tag collection
    void
    put(String key, String value)
    Sets a key/value pairs
    default void
    put(Tag tag)
    Sets a key/value pairs
    default void
    Add all key/value pairs.
    void
    Removes a given key/value pair
    void
    Removes all tags
    void
    Sets the map of key/value pairs
    default void
    Calls the visitor for every key/value pair.
  • Field Details

  • Method Details

    • setKeys

      void setKeys(Map<String,String> keys)
      Sets the map of key/value pairs
      Parameters:
      keys - the map of key value pairs. If null, reset to the empty map.
    • getKeys

      Replies the map of key/value pairs. Never null, but may be the empty map.
      Returns:
      the map of key/value pairs
    • visitKeys

      default void visitKeys(KeyValueVisitor visitor)
      Calls the visitor for every key/value pair.
      Parameters:
      visitor - The visitor to call.
      Since:
      13668
      See Also:
    • put

      void put(String key, String value)
      Sets a key/value pairs
      Parameters:
      key - the key
      value - the value. If null, removes the key/value pair.
    • put

      default void put(Tag tag)
      Sets a key/value pairs
      Parameters:
      tag - The tag to set.
      Since:
      10736
    • putAll

      default void putAll(Map<String,String> tags)
      Add all key/value pairs. This may be more performant than put(java.lang.String, java.lang.String), depending upon the implementation. By default, this calls put(java.lang.String, java.lang.String) for each map entry.
      Parameters:
      tags - The tag map to add
      Since:
      18473
    • get

      Replies the value of the given key; null, if there is no value for this key
      Parameters:
      key - the key
      Returns:
      the value
    • remove

      void remove(String key)
      Removes a given key/value pair
      Parameters:
      key - the key
    • hasKeys

      boolean hasKeys()
      Replies true, if there is at least one key/value pair; false, otherwise
      Returns:
      true, if there is at least one key/value pair; false, otherwise
    • hasKey

      default boolean hasKey(String key)
      Replies true if there is a tag with key key. The value could however be empty. See hasTag(String) to check for non-empty tags.
      Parameters:
      key - the key
      Returns:
      true, if there is a tag with key key
      Since:
      11608
      See Also:
    • hasTag

      default boolean hasTag(String key)
      Replies true if there is a non-empty tag with key key.
      Parameters:
      key - the key
      Returns:
      true, if there is a non-empty tag with key key
      Since:
      13430
      See Also:
    • hasTag

      default boolean hasTag(String key, String value)
      Tests whether this primitive contains a tag consisting of key and value.
      Parameters:
      key - the key forming the tag.
      value - value forming the tag.
      Returns:
      true if primitive contains a tag consisting of key and value.
      Since:
      13668
    • hasTag

      default boolean hasTag(String key, String... values)
      Tests whether this primitive contains a tag consisting of key and any of values.
      Parameters:
      key - the key forming the tag.
      values - one or many values forming the tag.
      Returns:
      true if primitive contains a tag consisting of key and any of values.
      Since:
      13668
    • hasTag

      default boolean hasTag(String key, Collection<String> values)
      Tests whether this primitive contains a tag consisting of key and any of values.
      Parameters:
      key - the key forming the tag.
      values - one or many values forming the tag.
      Returns:
      true if primitive contains a tag consisting of key and any of values.
      Since:
      13668
    • hasTagDifferent

      default boolean hasTagDifferent(String key, String value)
      Tests whether this primitive contains a tag consisting of key and a value different from value.
      Parameters:
      key - the key forming the tag.
      value - value not forming the tag.
      Returns:
      true if primitive contains a tag consisting of key and a value different from value.
      Since:
      13668
    • hasTagDifferent

      default boolean hasTagDifferent(String key, String... values)
      Tests whether this primitive contains a tag consisting of key and none of values.
      Parameters:
      key - the key forming the tag.
      values - one or many values forming the tag.
      Returns:
      true if primitive contains a tag consisting of key and none of values.
      Since:
      13668
    • hasTagDifferent

      default boolean hasTagDifferent(String key, Collection<String> values)
      Tests whether this primitive contains a tag consisting of key and none of values.
      Parameters:
      key - the key forming the tag.
      values - one or many values forming the tag.
      Returns:
      true if primitive contains a tag consisting of key and none of values.
      Since:
      13668
    • keySet

      Replies the set of keys
      Returns:
      the set of keys
      See Also:
    • keys

      default Stream<String> keys()
      Replies the keys as stream
      Returns:
      the keys as stream
      Since:
      17584
      See Also:
    • getNumKeys

      int getNumKeys()
      Gets the number of keys
      Returns:
      The number of keys set for this tagged object.
      Since:
      13625
    • removeAll

      void removeAll()
      Removes all tags
    • isKeyTrue

      default boolean isKeyTrue(String key)
      Returns true if the key corresponds to an OSM true value.
      Parameters:
      key - OSM key
      Returns:
      true if the key corresponds to an OSM true value
      See Also:
    • isKeyFalse

      default boolean isKeyFalse(String key)
      Returns true if the key corresponds to an OSM false value.
      Parameters:
      key - OSM key
      Returns:
      true if the key corresponds to an OSM false value
      See Also:
    • ofTags

      static Tagged ofTags(Collection<Tag> tags)
      Returns a Tagged instance for the given tag collection
      Parameters:
      tags - the tag collection
      Returns:
      a Tagged instance for the given tag collection
    • ofMap

      static Tagged ofMap(Map<String,String> tags)
      Returns a Tagged instance for the given tag map
      Parameters:
      tags - the tag map
      Returns:
      a Tagged instance for the given tag map