Package io.ocfl.core.model
Class VersionBuilder
- java.lang.Object
-
- io.ocfl.core.model.VersionBuilder
-
public class VersionBuilder extends Object
Used to construct Version objects.
-
-
Constructor Summary
Constructors Constructor Description VersionBuilder()
VersionBuilder(Version original)
Used to construct a new Version that's based on an existing version.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description VersionBuilder
addFile(String id, String logicalPath)
Adds a file to the version's stateVersion
build()
boolean
containsFileId(String fileId)
Indicates if the state contains the fileIdboolean
containsLogicalPath(String logicalPath)
Indicates if the state contains the logicalPathVersionBuilder
created(OffsetDateTime created)
String
getFileId(String logicalPath)
Retrieves the fileId associated to the logicalPathMap<String,String>
getInvertedState()
Returns a map of logical paths to file ids of all of the files in the version's stateSet<String>
getLogicalPaths(String fileId)
Retrieves all of the logical paths associated to the fileId or an empty setVersionBuilder
message(String message)
Set<String>
removeFileId(String fileId)
Removes a fileId from the stateString
removeLogicalPath(String logicalPath)
Removes a logical path from the stateVersionBuilder
state(PathBiMap state)
VersionBuilder
state(Map<String,Set<String>> state)
VersionBuilder
user(User user)
void
validateNonConflictingPath(String logicalPath)
Validates that the logical path does not conflict with any existing logical paths in this version.VersionBuilder
versionInfo(VersionInfo versionInfo)
-
-
-
Constructor Detail
-
VersionBuilder
public VersionBuilder()
-
VersionBuilder
public VersionBuilder(Version original)
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 Detail
-
addFile
public VersionBuilder addFile(String id, String logicalPath)
Adds a file to the version's state- Parameters:
id
- the fileIdlogicalPath
- the logical path to the file- Returns:
- builder
-
created
public VersionBuilder created(OffsetDateTime created)
-
message
public VersionBuilder message(String message)
-
user
public VersionBuilder user(User user)
-
versionInfo
public VersionBuilder versionInfo(VersionInfo versionInfo)
-
state
public VersionBuilder state(Map<String,Set<String>> state)
-
state
public VersionBuilder state(PathBiMap state)
-
build
public Version build()
- Returns:
- a new Version
-
containsFileId
public boolean containsFileId(String fileId)
Indicates if the state contains the fileId- Parameters:
fileId
- the fileId- Returns:
- true if the state contains the fileId
-
containsLogicalPath
public boolean containsLogicalPath(String logicalPath)
Indicates if the state contains the logicalPath- Parameters:
logicalPath
- the logicalPath- Returns:
- true if the state contains the logicalPath
-
validateNonConflictingPath
public void validateNonConflictingPath(String logicalPath)
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
public Set<String> getLogicalPaths(String fileId)
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
public String getFileId(String logicalPath)
Retrieves the fileId associated to the logicalPath- Parameters:
logicalPath
- the logicalPath- Returns:
- the fileId or null
-
removeLogicalPath
public String removeLogicalPath(String logicalPath)
Removes a logical path from the state- Parameters:
logicalPath
- the logicalPath- Returns:
- the fileId associated to the path or null
-
removeFileId
public Set<String> removeFileId(String fileId)
Removes a fileId from the state- Parameters:
fileId
- the fileId- Returns:
- the logical paths associated to the fileId
-
-