Class ObjectVersionId

java.lang.Object
io.ocfl.api.model.ObjectVersionId

public class ObjectVersionId extends Object
Points to a specific version of an object, encapsulating an object identifier and version number. When HEAD is specified, then it points to whatever the most recent version of the object is.
  • Method Details

    • head

      public static ObjectVersionId head(String objectId)
      Creates an ObjectId instance that points to the HEAD version of the object
      Parameters:
      objectId - the id of the object
      Returns:
      new ObjectVersionId
    • version

      public static ObjectVersionId version(String objectId, String versionNum)
      Creates an ObjectId instance that points to a specific version of an object
      Parameters:
      objectId - the id of the object
      versionNum - the OCFL version num of the version
      Returns:
      new ObjectVersionId
    • version

      public static ObjectVersionId version(String objectId, int versionNum)
      Creates an ObjectId instance that points to a specific version of an object
      Parameters:
      objectId - the id of the object
      versionNum - the OCFL version num of the version
      Returns:
      new ObjectVersionId
    • version

      public static ObjectVersionId version(String objectId, VersionNum versionNum)
      Creates an ObjectId instance that points to a specific version of an object
      Parameters:
      objectId - the id of the object
      versionNum - the OCFL version number of the version
      Returns:
      new ObjectVersionId
    • getObjectId

      public String getObjectId()
      The object id
      Returns:
      the object id
    • getVersionNum

      public VersionNum getVersionNum()
      The version number
      Returns:
      the version number or null if no version is specified
    • isHead

      public boolean isHead()
      Returns:
      true if no version number is set
    • nextVersion

      public ObjectVersionId nextVersion()
      Returns a new ObjectVersionId instance with an incremented version number. This may only be called if this instance has its version number set
      Returns:
      new ObjectVersionId with incremented version
      Throws:
      InvalidVersionException - if the version number is not set or the version cannot be incremented
    • previousVersion

      public ObjectVersionId previousVersion()
      Returns a new ObjectVersionId instance with an decremented version number. This may only be called if this instance has its version number set
      Returns:
      new ObjectVersionId with decremented version
      Throws:
      InvalidVersionException - if the version number is not set or the version cannot be decremented
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object