Class HistoryOsmPrimitive

    • Constructor Detail

      • HistoryOsmPrimitive

        protected HistoryOsmPrimitive​(long id,
                                      long version,
                                      boolean visible,
                                      User user,
                                      long changesetId,
                                      java.time.Instant timestamp)
        Constructs a new HistoryOsmPrimitive.
        Parameters:
        id - the id (> 0 required)
        version - the version (> 0 required)
        visible - whether the primitive is still visible
        user - the user (!= null required)
        changesetId - the changeset id (> 0 required)
        timestamp - the timestamp (!= null required)
        Throws:
        java.lang.IllegalArgumentException - if preconditions are violated
      • HistoryOsmPrimitive

        protected HistoryOsmPrimitive​(long id,
                                      long version,
                                      boolean visible,
                                      User user,
                                      long changesetId,
                                      java.time.Instant timestamp,
                                      boolean checkHistoricParams)
        Constructs a new HistoryOsmPrimitive with a configurable checking of historic parameters. This is needed to build virtual HistoryOsmPrimitives for modified primitives, which do not have a timestamp and a changeset id.
        Parameters:
        id - the id (> 0 required)
        version - the version (> 0 required)
        visible - whether the primitive is still visible
        user - the user (!= null required)
        changesetId - the changeset id (> 0 required if checkHistoricParams is true)
        timestamp - the timestamp (!= null required if checkHistoricParams is true)
        checkHistoricParams - if true, checks values of changesetId and timestamp
        Throws:
        java.lang.IllegalArgumentException - if preconditions are violated
        Since:
        5440
    • Method Detail

      • getId

        public long getId()
        Returns the id.
        Returns:
        the id
      • isVisible

        public boolean isVisible()
        Determines if the primitive is still visible.
        Returns:
        true if the primitive is still visible
      • getUser

        public User getUser()
        Returns the user.
        Returns:
        the user
      • getChangesetId

        public long getChangesetId()
        Returns the changeset id.
        Returns:
        the changeset id
      • getTimestamp

        @Deprecated
        public java.util.Date getTimestamp()
        Deprecated.
        Returns the timestamp.
        Returns:
        the timestamp
      • getInstant

        public java.time.Instant getInstant()
        Returns the timestamp.
        Returns:
        the timestamp
      • getVersion

        public long getVersion()
        Returns the version.
        Returns:
        the version
      • ensurePositiveLong

        protected final void ensurePositiveLong​(long value,
                                                java.lang.String name)
        Checks that value is positive.
        Parameters:
        value - value to check
        name - parameter name for error message
        Throws:
        java.lang.IllegalArgumentException - if value <= 0
      • matches

        public boolean matches​(long id,
                               long version)
        Determines if this history matches given id and version.
        Parameters:
        id - Primitive identifier
        version - Primitive version
        Returns:
        true if this history matches given id and version
      • matches

        public boolean matches​(long id)
        Determines if this history matches given id.
        Parameters:
        id - Primitive identifier
        Returns:
        true if this history matches given id
      • getUniqueId

        public final long getUniqueId()
        Description copied from interface: PrimitiveId
        Gets a unique id representing this object (the OSM server id for OSM objects)
        Specified by:
        getUniqueId in interface PrimitiveId
        Returns:
        the id number
      • isNew

        public final boolean isNew()
        Description copied from interface: PrimitiveId
        Replies true if this id represents a new primitive.
        Specified by:
        isNew in interface PrimitiveId
        Returns:
        true if this id represents a new primitive.
      • put

        public final void put​(java.lang.String key,
                              java.lang.String value)
        Description copied from interface: Tagged
        Sets a key/value pairs
        Specified by:
        put in interface Tagged
        Parameters:
        key - the key
        value - the value. If null, removes the key/value pair.
      • get

        public final java.lang.String get​(java.lang.String key)
        Description copied from interface: Tagged
        Replies the value of the given key; null, if there is no value for this key
        Specified by:
        get in interface Tagged
        Parameters:
        key - the key
        Returns:
        the value
      • hasKey

        public final boolean hasKey​(java.lang.String key)
        Description copied from interface: Tagged
        Replies true if there is a tag with key key. The value could however be empty. See Tagged.hasTag(String) to check for non-empty tags.
        Specified by:
        hasKey in interface Tagged
        Parameters:
        key - the key
        Returns:
        true, if there is a tag with key key
        See Also:
        Tagged.hasTag(String)
      • getKeys

        public final java.util.Map<java.lang.String,​java.lang.String> getKeys()
        Description copied from interface: Tagged
        Replies the map of key/value pairs. Never null, but may be the empty map.
        Specified by:
        getKeys in interface Tagged
        Returns:
        the map of key/value pairs
      • setKeys

        public final void setKeys​(java.util.Map<java.lang.String,​java.lang.String> keys)
        Description copied from interface: Tagged
        Sets the map of key/value pairs
        Specified by:
        setKeys in interface Tagged
        Parameters:
        keys - the map of key value pairs. If null, reset to the empty map.
      • remove

        public final void remove​(java.lang.String key)
        Description copied from interface: Tagged
        Removes a given key/value pair
        Specified by:
        remove in interface Tagged
        Parameters:
        key - the key
      • hasKeys

        public final boolean hasKeys()
        Description copied from interface: Tagged
        Replies true, if there is at least one key/value pair; false, otherwise
        Specified by:
        hasKeys in interface Tagged
        Returns:
        true, if there is at least one key/value pair; false, otherwise
      • keySet

        public final java.util.Collection<java.lang.String> keySet()
        Description copied from interface: Tagged
        Replies the set of keys
        Specified by:
        keySet in interface Tagged
        Returns:
        the set of keys
        See Also:
        Tagged.keys()
      • getNumKeys

        public int getNumKeys()
        Description copied from interface: Tagged
        Gets the number of keys
        Specified by:
        getNumKeys in interface Tagged
        Returns:
        The number of keys set for this tagged object.
      • getTags

        public java.util.Map<java.lang.String,​java.lang.String> getTags()
        Replies the key/value map.
        Returns:
        the key/value map
      • getChangeset

        public Changeset getChangeset()
        Returns the changeset for this history primitive.
        Returns:
        the changeset for this history primitive
      • setChangeset

        public void setChangeset​(Changeset changeset)
        Sets the changeset for this history primitive.
        Parameters:
        changeset - the changeset for this history primitive
      • setTags

        public void setTags​(java.util.Map<java.lang.String,​java.lang.String> tags)
        Sets the tags for this history primitive. Removes all tags if tags is null.
        Parameters:
        tags - the tags. May be null.
      • getName

        public java.lang.String getName()
        Replies the name of this primitive. The default implementation replies the value of the tag name or null, if this tag is not present.
        Returns:
        the name of this primitive
      • getDisplayName

        public abstract java.lang.String getDisplayName​(HistoryNameFormatter formatter)
        Replies the display name of a primitive formatted by formatter
        Parameters:
        formatter - The formatter used to generate a display name
        Returns:
        the display name
      • getLocalName

        public java.lang.String getLocalName()
        Replies the a localized name for this primitive given by the value of the tags (in this order)
        • name:lang_COUNTRY_Variant of the current locale
        • name:lang_COUNTRY of the current locale
        • name:lang of the current locale
        • name of the current locale
        null, if no such tag exists
        Returns:
        the name of this primitive
      • fillPrimitiveCommonData

        protected void fillPrimitiveCommonData​(PrimitiveData data)
        Fills the attributes common to all primitives with values from this history.
        Parameters:
        data - primitive data to fill
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object