Class InventoryBuilder


  • public class InventoryBuilder
    extends Object
    Used to construct Inventory objects.
    • Constructor Detail

      • InventoryBuilder

        public InventoryBuilder()
      • InventoryBuilder

        public InventoryBuilder​(Inventory original)
        Used to construct a new Inventory that's based on an existing inventory. This should be used when creating a new version of an existing object.
        Parameters:
        original - the original inventory
    • Method Detail

      • addHeadVersion

        public InventoryBuilder addHeadVersion​(Version version)
        Add the version as the new HEAD version. This assigns the version the next available version number, unless it's mutable.
        Parameters:
        version - the new version
        Returns:
        builder
      • putVersion

        public InventoryBuilder putVersion​(VersionNum versionNum,
                                           Version version)
        Inserts a version at the specified version number. This will OVERWRITE any version that is currently at that location.
        Parameters:
        versionNum - the id of the version
        version - the version
        Returns:
        builder
      • addFileToManifest

        public InventoryBuilder addFileToManifest​(String id,
                                                  String contentPath)
        Adds a file to the manifest
        Parameters:
        id - the fileId of the file
        contentPath - the content path of the file
        Returns:
        builder
      • removeFileId

        public InventoryBuilder removeFileId​(String fileId)
        Removes a file from the manifest and fixity block
        Parameters:
        fileId - the fileId of the file
        Returns:
        builder
      • removeContentPath

        public InventoryBuilder removeContentPath​(String contentPath)
        Removes a file from the manifest and fixity bock by content path
        Parameters:
        contentPath - the content path of the file to remove
        Returns:
        builder
      • removeContentPathFromFixity

        public InventoryBuilder removeContentPathFromFixity​(String contentPath)
        Removes a file from the fixity block by content path
        Parameters:
        contentPath - the content path of the file to remove
        Returns:
        builder
      • addFixityForFile

        public InventoryBuilder addFixityForFile​(String contentPath,
                                                 DigestAlgorithm algorithm,
                                                 String value)
        Adds a file to the fixity block
        Parameters:
        contentPath - the content path of the file
        algorithm - digest algorithm
        value - digest value
        Returns:
        builder
      • clearFixity

        public InventoryBuilder clearFixity()
        Removes all of the entries from the fixity block.
        Returns:
        builder
      • build

        public Inventory build()
        Returns:
        a new Inventory
      • containsFileId

        public boolean containsFileId​(String fileId)
        Indicates if the manifest contains a fileId
        Parameters:
        fileId - the fileId
        Returns:
        true if the manifest contains the fileId
      • containsContentPath

        public boolean containsContentPath​(String contentPath)
        Indicates if the manifest contains a contentPath
        Parameters:
        contentPath - the contentPath
        Returns:
        true if the manifest contains the contentPath
      • getContentPaths

        public Set<String> getContentPaths​(String fileId)
        Retrieves the content paths associated to the fileId or an empty set
        Parameters:
        fileId - the fileId
        Returns:
        associated content paths or an empty set
      • getFileId

        public String getFileId​(String contentPath)
        Retrieves the fileId associated to the content path
        Parameters:
        contentPath - the contentPath
        Returns:
        associated fileId or null
      • hasMutableHead

        public boolean hasMutableHead()
      • getFileFixity

        public String getFileFixity​(String fileId,
                                    DigestAlgorithm algorithm)
        Returns the fixity digest for a file or null
        Parameters:
        fileId - the fileId
        algorithm - the digest algorithm
        Returns:
        digest or null