Class Version
java.lang.Object
org.gcube.informationsystem.utils.Version
- All Implemented Interfaces:
Comparable<Version>
A class representing and validating a version in the following format X.X.X (Major.Minor.Revision)
Each part is an integer with no trailing zeros (e.g 1 and not 01).
The version is validated by the regex defined in the static field
VERSION_REGEX
Accepted initial version is MINIMAL_VERSION_STRING- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe major version number.static final VersionAccepted initial version as TypeVersion instancestatic final StringDefault changelog description for the initial versionstatic final StringAccepted initial versionprotected intThe minor version number.protected intThe revision number.static final StringRegex validating the version -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheck()Checks if the version is valid.intbooleanintgetMajor()Gets the major version number.intgetMinor()Gets the minor version number.intGets the revision number.inthashCode()protected voidsetMajor(int major) Sets the major version number.protected voidsetMinor(int minor) Sets the minor version number.protected voidsetRevision(int revision) Sets the revision number.voidsetVersion(String version) Sets the version from a string.toString()
-
Field Details
-
VERSION_REGEX
Regex validating the version- See Also:
-
MINIMAL_VERSION_STRING
Accepted initial version- See Also:
-
MINIMAL_VERSION
Accepted initial version as TypeVersion instance -
MINIMAL_VERSION_DESCRIPTION
Default changelog description for the initial version- See Also:
-
major
protected int majorThe major version number. -
minor
protected int minorThe minor version number. -
revision
protected int revisionThe revision number.
-
-
Constructor Details
-
Version
protected Version()Default constructor. -
Version
Constructs a new Version from a string.- Parameters:
version- the version string
-
Version
public Version(int major, int minor, int revision) Constructs a new Version from its major, minor, and revision numbers.- Parameters:
major- the major version numberminor- the minor version numberrevision- the revision number
-
-
Method Details
-
setVersion
Sets the version from a string.- Parameters:
version- the version string
-
check
protected void check()Checks if the version is valid. -
getMajor
public int getMajor()Gets the major version number.- Returns:
- the major version number
-
setMajor
protected void setMajor(int major) Sets the major version number.- Parameters:
major- the major version number
-
getMinor
public int getMinor()Gets the minor version number.- Returns:
- the minor version number
-
setMinor
protected void setMinor(int minor) Sets the minor version number.- Parameters:
minor- the minor version number
-
getRevision
public int getRevision()Gets the revision number.- Returns:
- the revision number
-
setRevision
protected void setRevision(int revision) Sets the revision number.- Parameters:
revision- the revision number
-
toString
-
compareTo
- Specified by:
compareToin interfaceComparable<Version>
-
hashCode
public int hashCode() -
equals
-