Package io.ocfl.api.model
Class VersionNum
java.lang.Object
io.ocfl.api.model.VersionNum
- All Implemented Interfaces:
Comparable<VersionNum>
Represents an OCFL version number. It is able to handle zero-padded version numbers.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionVersionNum
(long versionNumber) Creates a new VersionNum.VersionNum
(long versionNumber, int zeroPaddingWidth) Creates a new VersionNum -
Method Summary
Modifier and TypeMethodDescriptionint
boolean
static VersionNum
fromInt
(int versionNumber) Creates a new VersionNum from an integer.static VersionNum
fromString
(String value) Creates a new VersionNum from a version string in the format of "vN" where "N" is an integer greater than -1.long
int
int
hashCode()
Returns a new VersionNum that is one more than this.Returns a new VersionNum that is one less than this.toString()
-
Field Details
-
V1
-
-
Constructor Details
-
VersionNum
public VersionNum(long versionNumber) Creates a new VersionNum. Zero-padding is not used.- Parameters:
versionNumber
- the version number, must be greater than -1
-
VersionNum
public VersionNum(long versionNumber, int zeroPaddingWidth) Creates a new VersionNum- Parameters:
versionNumber
- the version number, must be greater than -1zeroPaddingWidth
- the width of zero-padding, or 0 if the version is not zero-padded
-
-
Method Details
-
fromString
Creates a new VersionNum from a version string in the format of "vN" where "N" is an integer greater than -1. Zero-padded values are supported.- Parameters:
value
- version string- Returns:
- version number
-
fromInt
Creates a new VersionNum from an integer.- Parameters:
versionNumber
- the version number, must be greater than -1- Returns:
- version number
-
nextVersionNum
Returns a new VersionNum that is one more than this. If the version number is zero-padded, versions higher than the max number are now allowed.- Returns:
- a new VersionNum with an incremented version number
- Throws:
InvalidVersionException
- if the next version is higher than the max allowed value
-
previousVersionNum
Returns a new VersionNum that is one less than this. Version numbers lower than 0 are not allowed.- Returns:
- a new VersionNum with a decremented version number
- Throws:
InvalidVersionException
- if the previous version is lower than 1
-
getZeroPaddingWidth
public int getZeroPaddingWidth()- Returns:
- the zero-padding width, 0 when not padded
-
getVersionNum
public long getVersionNum()- Returns:
- the numeric version number
-
equals
-
hashCode
public int hashCode() -
toString
-
compareTo
- Specified by:
compareTo
in interfaceComparable<VersionNum>
-