Package org.syncany.database
Class PartialFileHistory
- java.lang.Object
-
- org.syncany.database.PartialFileHistory
-
public class PartialFileHistory extends java.lang.Object
APartialFileHistoryrepresents a single file in a repository over a certain period of time/versions. Whenever a file is updated or deleted, a newFileVersionis 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 classPartialFileHistory.FileHistoryIdThe 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.FileHistoryIdas identifier of the file over time.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFileVersion(FileVersion fileVersion)Adds a new file version of the file history.PartialFileHistoryclone()Clones the file history, including its file versions.booleanequals(java.lang.Object obj)PartialFileHistory.FileHistoryIdgetFileHistoryId()Returns the file history identifier for this file history.FileVersiongetFileVersion(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 theFileVersions, keyed by the version number of the corresponding file version.FileVersiongetLastVersion()Returns the last file version in this instance of the partial file history, ornullif there are no file versions.inthashCode()java.lang.StringtoString()
-
-
-
Constructor Detail
-
PartialFileHistory
public PartialFileHistory()
-
PartialFileHistory
public PartialFileHistory(PartialFileHistory.FileHistoryId fileHistoryId)
Creates a new file history instance, given aPartialFileHistory.FileHistoryIdas 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 theFileVersions, 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, ornullif 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:
clonein classjava.lang.Object- Returns:
- Returns cloned file history
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-