Package io.ocfl.core.model
Class VersionBuilder
java.lang.Object
io.ocfl.core.model.VersionBuilder
Used to construct Version objects.
-
Constructor Summary
ConstructorsConstructorDescriptionVersionBuilder
(Version original) Used to construct a new Version that's based on an existing version. -
Method Summary
Modifier and TypeMethodDescriptionAdds a file to the version's statebuild()
boolean
containsFileId
(String fileId) Indicates if the state contains the fileIdboolean
containsLogicalPath
(String logicalPath) Indicates if the state contains the logicalPathcreated
(OffsetDateTime created) Retrieves the fileId associated to the logicalPathReturns a map of logical paths to file ids of all of the files in the version's stategetLogicalPaths
(String fileId) Retrieves all of the logical paths associated to the fileId or an empty setremoveFileId
(String fileId) Removes a fileId from the stateremoveLogicalPath
(String logicalPath) Removes a logical path from the statevoid
validateNonConflictingPath
(String logicalPath) Validates that the logical path does not conflict with any existing logical paths in this version.versionInfo
(VersionInfo versionInfo)
-
Constructor Details
-
VersionBuilder
public VersionBuilder() -
VersionBuilder
Used to construct a new Version that's based on an existing version. The existing version's state is copied over to the new version.- Parameters:
original
- the original version
-
-
Method Details
-
addFile
Adds a file to the version's state- Parameters:
id
- the fileIdlogicalPath
- the logical path to the file- Returns:
- builder
-
created
-
message
-
user
-
versionInfo
-
state
-
state
-
build
- Returns:
- a new Version
-
containsFileId
Indicates if the state contains the fileId- Parameters:
fileId
- the fileId- Returns:
- true if the state contains the fileId
-
containsLogicalPath
Indicates if the state contains the logicalPath- Parameters:
logicalPath
- the logicalPath- Returns:
- true if the state contains the logicalPath
-
validateNonConflictingPath
Validates that the logical path does not conflict with any existing logical paths in this version. Paths conflict if one expects a path to be a directory and another expects it to be a file.- Parameters:
logicalPath
- the logical path- Throws:
OcflInputException
- if there is a conflict
-
getLogicalPaths
Retrieves all of the logical paths associated to the fileId or an empty set- Parameters:
fileId
- the fileId- Returns:
- associated logical paths or an empty set
-
getFileId
Retrieves the fileId associated to the logicalPath- Parameters:
logicalPath
- the logicalPath- Returns:
- the fileId or null
-
removeLogicalPath
Removes a logical path from the state- Parameters:
logicalPath
- the logicalPath- Returns:
- the fileId associated to the path or null
-
removeFileId
Removes a fileId from the state- Parameters:
fileId
- the fileId- Returns:
- the logical paths associated to the fileId
-
getInvertedState
Returns a map of logical paths to file ids of all of the files in the version's state- Returns:
- map of logical paths to file ids
-