Package org.syncany.database
Class PartialFileHistory
- java.lang.Object
-
- org.syncany.database.PartialFileHistory
-
public class PartialFileHistory extends java.lang.Object
APartialFileHistory
represents a single file in a repository over a certain period of time/versions. Whenever a file is updated or deleted, a newFileVersion
is added to the file history.A file history is identified by a unique random identifier and holds a sorted list of file versions.
Due to cleanup mechanisms and the delta database concept, the list of file versions is not always complete. The class hence represents a part of the file history.
- See Also:
FileVersion
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PartialFileHistory.FileHistoryId
The file history identifier (also: file identifier) is a key to identify a single file throughout its lifetime.
-
Constructor Summary
Constructors Constructor Description PartialFileHistory()
PartialFileHistory(PartialFileHistory.FileHistoryId fileHistoryId)
Creates a new file history instance, given aPartialFileHistory.FileHistoryId
as identifier of the file over time.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFileVersion(FileVersion fileVersion)
Adds a new file version of the file history.PartialFileHistory
clone()
Clones the file history, including its file versions.boolean
equals(java.lang.Object obj)
PartialFileHistory.FileHistoryId
getFileHistoryId()
Returns the file history identifier for this file history.FileVersion
getFileVersion(long version)
Returns the file version with the given file version number, or null if a version with this number does not exist in this file history.java.util.Map<java.lang.Long,FileVersion>
getFileVersions()
Returns an unmodifiable map of theFileVersion
s, keyed by the version number of the corresponding file version.FileVersion
getLastVersion()
Returns the last file version in this instance of the partial file history, ornull
if there are no file versions.int
hashCode()
java.lang.String
toString()
-
-
-
Constructor Detail
-
PartialFileHistory
public PartialFileHistory()
-
PartialFileHistory
public PartialFileHistory(PartialFileHistory.FileHistoryId fileHistoryId)
Creates a new file history instance, given aPartialFileHistory.FileHistoryId
as identifier of the file over time. After creation, the file history's versions map is empty.- Parameters:
fileHistoryId
- Random or non-random file history identifier- Throws:
java.lang.IllegalArgumentException
- If fileHistoryId is null
-
-
Method Detail
-
getFileHistoryId
public PartialFileHistory.FileHistoryId getFileHistoryId()
Returns the file history identifier for this file history. Note that this value cannot be null.
-
getFileVersions
public java.util.Map<java.lang.Long,FileVersion> getFileVersions()
Returns an unmodifiable map of theFileVersion
s, keyed by the version number of the corresponding file version.
-
getFileVersion
public FileVersion getFileVersion(long version)
Returns the file version with the given file version number, or null if a version with this number does not exist in this file history.
-
getLastVersion
public FileVersion getLastVersion()
Returns the last file version in this instance of the partial file history, ornull
if there are no file versions.Note that this method does not necessarily return the actual overall last file version, only the last of this object instance.
- Returns:
- Returns the last file version, or
null
-
addFileVersion
public void addFileVersion(FileVersion fileVersion)
Adds a new file version of the file history. The given file version is added to an internal tree map, sorted by the attributeFileVersion.getVersion()
. If a file version version with the same version already exists, it is replaced by the given file version.- Parameters:
fileVersion
- File version to be added to the file history- Throws:
java.lang.IllegalArgumentException
- If fileVersion or its version number isnull
-
clone
public PartialFileHistory clone()
Clones the file history, including its file versions. Note that file versions are not cloned, but copied by reference.- Overrides:
clone
in classjava.lang.Object
- Returns:
- Returns cloned file history
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-