Class VersionBuilder

java.lang.Object
io.ocfl.core.model.VersionBuilder

public class VersionBuilder extends Object
Used to construct Version objects.
  • Constructor Details

    • 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 Details

    • addFile

      public VersionBuilder addFile(String id, String logicalPath)
      Adds a file to the version's state
      Parameters:
      id - the fileId
      logicalPath - 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
    • getInvertedState

      public Map<String,String> 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