Class Version
- java.lang.Object
-
- org.gcube.informationsystem.utils.Version
-
- All Implemented Interfaces:
Comparable<Version>
public final class Version extends Object implements 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 fieldVERSION_REGEXAccepted initial version isMINIMAL_VERSION_STRING- Author:
- Luca Frosini (ISTI - CNR)
-
-
Field Summary
Fields Modifier and Type Field Description protected intmajorThe major version number.static VersionMINIMAL_VERSIONAccepted initial version as TypeVersion instancestatic StringMINIMAL_VERSION_DESCRIPTIONDefault changelog description for the initial versionstatic StringMINIMAL_VERSION_STRINGAccepted initial versionprotected intminorThe minor version number.protected intrevisionThe revision number.static StringVERSION_REGEXRegex validating the version
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheck()Checks if the version is valid.intcompareTo(Version other)booleanequals(Object obj)intgetMajor()Gets the major version number.intgetMinor()Gets the minor version number.intgetRevision()Gets 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.StringtoString()
-
-
-
Field Detail
-
VERSION_REGEX
public static final String VERSION_REGEX
Regex validating the version- See Also:
- Constant Field Values
-
MINIMAL_VERSION_STRING
public static final String MINIMAL_VERSION_STRING
Accepted initial version- See Also:
- Constant Field Values
-
MINIMAL_VERSION
public static final Version MINIMAL_VERSION
Accepted initial version as TypeVersion instance
-
MINIMAL_VERSION_DESCRIPTION
public static final String MINIMAL_VERSION_DESCRIPTION
Default changelog description for the initial version- See Also:
- Constant Field Values
-
major
protected int major
The major version number.
-
minor
protected int minor
The minor version number.
-
revision
protected int revision
The revision number.
-
-
Constructor Detail
-
Version
protected Version()
Default constructor.
-
Version
public Version(String 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 Detail
-
setVersion
public void setVersion(String version)
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
-
compareTo
public int compareTo(Version other)
- Specified by:
compareToin interfaceComparable<Version>
-
-