Package org.eclipse.rdf4j.common.app
Class AppVersion
java.lang.Object
org.eclipse.rdf4j.common.app.AppVersion
- All Implemented Interfaces:
Comparable<AppVersion>
A product version in Aduna's version format (i.e. major.minor-modifier). Where major stands for the major version
number of the release, minor is the minor version number, and modifier is a modifier for the release, e.g. beta1 or
RC1. Combined, this results in versions like 2.0 and 4.1-beta1.
-
Constructor Summary
ConstructorDescriptionConstruct an uninitialized AppVersion.AppVersion
(int major, int minor) Creates a new major.minor version number, e.g.1.0.AppVersion
(int major, int minor, int patch) Creates a new major.minor.patch version number, e.g.1.0.1.AppVersion
(int major, int minor, int patch, int milestone, String modifier) Creates a new major.minor.patchMmilestone-modifier version number, e.g.1.0.1M1-SNAPSHOT.AppVersion
(int major, int minor, int patch, int milestone, String modifier, String build) Creates a new version numberAppVersion
(int major, int minor, int patch, String modifier) Creates a new major.minor.patch-modifier version number, e.g.1.0.1-SNAPSHOT.AppVersion
(int major, int minor, String modifier) Creates a new major.minor-modifier version number, e.g.1.0-beta1. -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(AppVersion other) Compares two version numbers according to their major, minor, patch and milestone version numbers, ordering from oldest to newest version.boolean
Check if two versions are exactly equal, modifier is case insensitive.int
getMajor()
Gets the version's major version number.int
Get the milestone numberint
getMinor()
Gets the version's minor version number.Gets the version's release modifier part.int
getPatch()
Gets the version's micro version / patch level number.int
hashCode()
boolean
newerThan
(AppVersion other) Checks if this version is newer than the specified version, according to the result ofcompareTo(AppVersion)
.boolean
olderThan
(AppVersion other) Checks if this version is older than the specified version, according to the result ofcompareTo(AppVersion)
.static AppVersion
Parses a version string into a Version object.void
setMajor
(int major) Set major numbervoid
setMilestone
(int milestone) Set the milestone numbervoid
setMinor
(int minor) Set minor numbervoid
setModifier
(String modifier) Set the version's release modifier part.void
setPatch
(int micro) Sets the version's micro version / patch level number.toString()
Returns the string represention of this version.
-
Constructor Details
-
AppVersion
public AppVersion()Construct an uninitialized AppVersion. -
AppVersion
public AppVersion(int major, int minor) Creates a new major.minor version number, e.g.1.0.- Parameters:
major
- major numberminor
- minor number
-
AppVersion
public AppVersion(int major, int minor, int patch) Creates a new major.minor.patch version number, e.g.1.0.1.- Parameters:
major
- major numberminor
- minor numberpatch
- patch number
-
AppVersion
Creates a new major.minor-modifier version number, e.g.1.0-beta1.- Parameters:
major
- major numberminor
- minor numbermodifier
- additional string
-
AppVersion
Creates a new major.minor.patch-modifier version number, e.g.1.0.1-SNAPSHOT.- Parameters:
major
- major numberminor
- minor numberpatch
- patch numbermodifier
- additional string
-
AppVersion
Creates a new major.minor.patchMmilestone-modifier version number, e.g.1.0.1M1-SNAPSHOT.- Parameters:
major
- major numberminor
- minor numberpatch
- patch numbermilestone
- milestone numbermodifier
- additional string
-
AppVersion
Creates a new version number- Parameters:
major
- major numberminor
- minor numberpatch
- patch numbermilestone
- milestone numbermodifier
- additional stringbuild
- build string
-
-
Method Details
-
getMajor
public int getMajor()Gets the version's major version number.- Returns:
- major number
-
setMajor
public void setMajor(int major) Set major number- Parameters:
major
- major number
-
getMinor
public int getMinor()Gets the version's minor version number.- Returns:
- minor number
-
setMinor
public void setMinor(int minor) Set minor number- Parameters:
minor
- minor number
-
getPatch
public int getPatch()Gets the version's micro version / patch level number.- Returns:
- patch level number
-
setPatch
public void setPatch(int micro) Sets the version's micro version / patch level number.- Parameters:
micro
- patch level number
-
setMilestone
public void setMilestone(int milestone) Set the milestone number- Parameters:
milestone
- milestone number
-
getMilestone
public int getMilestone()Get the milestone number- Returns:
- milestone number
-
getModifier
Gets the version's release modifier part.- Returns:
- modifier string
-
setModifier
Set the version's release modifier part.- Parameters:
modifier
- modifier string
-
equals
Check if two versions are exactly equal, modifier is case insensitive. -
hashCode
public int hashCode() -
olderThan
Checks if this version is older than the specified version, according to the result ofcompareTo(AppVersion)
.- Parameters:
other
- other version- Returns:
- true if this version is older than other
-
newerThan
Checks if this version is newer than the specified version, according to the result ofcompareTo(AppVersion)
.- Parameters:
other
- other version- Returns:
- true if this version is newer than other
-
compareTo
Compares two version numbers according to their major, minor, patch and milestone version numbers, ordering from oldest to newest version. If all version numbers are equal, then their modifiers are compared lexicographically (based on the Unicode value of each character), ignoring case. Versions without a modifier or milestone are considered to be the "final" versions and come after other versions with a modifier or milestone.- Specified by:
compareTo
in interfaceComparable<AppVersion>
- Parameters:
other
-- Returns:
- 0 if both versions are equal, a negative number if this version is older than other, or a positive number otherwise.
-
parse
Parses a version string into a Version object.- Parameters:
versionString
- A version string, e.g. 1.0.1 or 1.0-beta1.- Returns:
- The parsed Version.
- Throws:
NumberFormatException
- If versionString could not be parsed to a version.
-
toString
Returns the string represention of this version.
-