Class History
- java.lang.Object
-
- org.openstreetmap.josm.data.osm.history.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static interface
History.FilterPredicate
-
Field Summary
Fields Modifier and Type Field Description private long
id
the object idprivate OsmPrimitiveType
type
the object typeprivate java.util.List<HistoryOsmPrimitive>
versions
the list of object snapshots
-
Constructor Summary
Constructors Modifier Constructor Description protected
History(long id, OsmPrimitiveType type, java.util.List<HistoryOsmPrimitive> versions)
Creates a new history for an OSM primitive.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description History
between(long fromVersion, long untilVersion)
Returns a new partial copy of this history, between the given version numbersHistory
between(java.time.Instant fromDate, java.time.Instant untilDate)
Returns a new partial copy of this history, between the given datesboolean
contains(long version)
Determines if this history contains a specific version number.private static History
filter(History history, History.FilterPredicate predicate)
History
forUserId(long uid)
Returns a new partial copy of this history, for the given user idHistory
from(long fromVersion)
Returns a new partial copy of this history, from the given version numberHistory
from(java.time.Instant fromDate)
Returns a new partial copy of this history, from the given dateHistoryOsmPrimitive
get(int idx)
Replies the history primitive at indexidx
.HistoryOsmPrimitive
getByDate(java.time.Instant date)
Replies the history primitive at givendate
.HistoryOsmPrimitive
getByVersion(long version)
Replies the history primitive with versionversion
.HistoryOsmPrimitive
getEarliest()
Replies the earliest entry of this history.long
getId()
Replies the primitive id for this history.HistoryOsmPrimitive
getLatest()
Replies the latest entry of this history.int
getNumVersions()
Replies the number of versions.PrimitiveId
getPrimitiveId()
Replies the primitive id for this history.OsmPrimitiveType
getType()
Replies the primitive type for this history.HistoryOsmPrimitive
getWhichChangedTag(HistoryOsmPrimitive primitive, java.lang.String key, boolean isLatest)
Replies the history primitive which changed the given key.boolean
isEmpty()
Returns true if this history contains no version.History
sortAscending()
Returns a new copy of this history, sorted in ascending order.History
sortDescending()
Returns a new copy of this history, sorted in descending order.java.lang.String
toString()
History
until(long untilVersion)
Returns a new partial copy of this history, to the given version numberHistory
until(java.time.Instant untilDate)
Returns a new partial copy of this history, until the given date
-
-
-
Field Detail
-
versions
private final java.util.List<HistoryOsmPrimitive> versions
the list of object snapshots
-
id
private final long id
the object id
-
type
private final OsmPrimitiveType type
the object type
-
-
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 <= 0java.lang.IllegalArgumentException
- if type is null
-
-
Method Detail
-
filter
private static History filter(History history, History.FilterPredicate predicate)
-
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 dateuntilDate
- 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 numberuntilVersion
- 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
-
getId
public long getId()
Replies the primitive id for this history.- Returns:
- the primitive id
- See Also:
getPrimitiveId()
,getType()
-
getPrimitiveId
public PrimitiveId getPrimitiveId()
Replies the primitive id for this history.- Returns:
- the primitive id
- See Also:
getId()
-
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 containsversion
,false
otherwise
-
getByVersion
public HistoryOsmPrimitive getByVersion(long version)
Replies the history primitive with versionversion
. 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 keyisLatest
- 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 givendate
. 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 indexidx
.- Parameters:
idx
- the index- Returns:
- the history primitive at index
idx
- Throws:
java.lang.IndexOutOfBoundsException
- if index out or range
-
getEarliest
public HistoryOsmPrimitive getEarliest()
Replies the earliest entry of this history.- Returns:
- the earliest entry of this history
-
getLatest
public HistoryOsmPrimitive getLatest()
Replies the latest entry of this history.- Returns:
- the latest entry of this history
-
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
-
getType
public OsmPrimitiveType getType()
Replies the primitive type for this history.- Returns:
- the primitive type
- See Also:
getId()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-