Class History


  • public class History
    extends java.lang.Object
    Represents the history of an OSM primitive. The history consists of a list of object snapshots with a specific version.
    Since:
    1670
    • Constructor Detail

      • History

        protected History​(long id,
                          OsmPrimitiveType type,
                          java.util.List<HistoryOsmPrimitive> versions)
        Creates a new history for an OSM primitive.
        Parameters:
        id - the id. > 0 required.
        type - the primitive type. Must not be null.
        versions - a list of versions. Can be null.
        Throws:
        java.lang.IllegalArgumentException - if id <= 0
        java.lang.IllegalArgumentException - if type is null
    • Method Detail

      • sortAscending

        public History sortAscending()
        Returns a new copy of this history, sorted in ascending order.
        Returns:
        a new copy of this history, sorted in ascending order
      • sortDescending

        public History sortDescending()
        Returns a new copy of this history, sorted in descending order.
        Returns:
        a new copy of this history, sorted in descending order
      • from

        public History from​(java.time.Instant fromDate)
        Returns a new partial copy of this history, from the given date
        Parameters:
        fromDate - the starting date
        Returns:
        a new partial copy of this history, from the given date
      • until

        public History until​(java.time.Instant untilDate)
        Returns a new partial copy of this history, until the given date
        Parameters:
        untilDate - the end date
        Returns:
        a new partial copy of this history, until the given date
      • between

        public History between​(java.time.Instant fromDate,
                               java.time.Instant untilDate)
        Returns a new partial copy of this history, between the given dates
        Parameters:
        fromDate - the starting date
        untilDate - the end date
        Returns:
        a new partial copy of this history, between the given dates
      • from

        public History from​(long fromVersion)
        Returns a new partial copy of this history, from the given version number
        Parameters:
        fromVersion - the starting version number
        Returns:
        a new partial copy of this history, from the given version number
      • until

        public History until​(long untilVersion)
        Returns a new partial copy of this history, to the given version number
        Parameters:
        untilVersion - the ending version number
        Returns:
        a new partial copy of this history, to the given version number
      • between

        public History between​(long fromVersion,
                               long untilVersion)
        Returns a new partial copy of this history, between the given version numbers
        Parameters:
        fromVersion - the starting version number
        untilVersion - the ending version number
        Returns:
        a new partial copy of this history, between the given version numbers
      • forUserId

        public History forUserId​(long uid)
        Returns a new partial copy of this history, for the given user id
        Parameters:
        uid - the user id
        Returns:
        a new partial copy of this history, for the given user id
      • contains

        public boolean contains​(long version)
        Determines if this history contains a specific version number.
        Parameters:
        version - the version number to look for
        Returns:
        true if this history contains version, false otherwise
      • getByVersion

        public HistoryOsmPrimitive getByVersion​(long version)
        Replies the history primitive with version version. null, if no such primitive exists.
        Parameters:
        version - the version
        Returns:
        the history primitive with version version
      • getWhichChangedTag

        public HistoryOsmPrimitive getWhichChangedTag​(HistoryOsmPrimitive primitive,
                                                      java.lang.String key,
                                                      boolean isLatest)
        Replies the history primitive which changed the given key.
        Parameters:
        primitive - the reference primitive (the history up to and including this primitive is considered)
        key - the OSM key
        isLatest - whether this relates to a not yet committed changeset
        Returns:
        the history primitive which changed the given key
      • getByDate

        public HistoryOsmPrimitive getByDate​(java.time.Instant date)
        Replies the history primitive at given date. null, if no such primitive exists.
        Parameters:
        date - the date
        Returns:
        the history primitive at given date
      • get

        public HistoryOsmPrimitive get​(int idx)
        Replies the history primitive at index idx.
        Parameters:
        idx - the index
        Returns:
        the history primitive at index idx
        Throws:
        java.lang.IndexOutOfBoundsException - if index out or range
      • getNumVersions

        public int getNumVersions()
        Replies the number of versions.
        Returns:
        the number of versions
      • isEmpty

        public final boolean isEmpty()
        Returns true if this history contains no version.
        Returns:
        true if this history contains no version, false otherwise
      • toString

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