Package org.eclipse.rdf4j.common.app
Class AppVersion
- java.lang.Object
-
- org.eclipse.rdf4j.common.app.AppVersion
-
- All Implemented Interfaces:
java.lang.Comparable<AppVersion>
public class AppVersion extends java.lang.Object implements java.lang.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.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
build
The version's build, if any.private int
major
The version's major version number.private int
milestone
The version's milestone number, if any.private int
minor
The version's minor version number.private java.lang.String
modifier
The version's modifier, if any.private int
patch
The version's patch version number, if any.private static java.util.regex.Pattern
VERSION_REGEX
-
Constructor Summary
Constructors Constructor Description AppVersion()
Construct 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, java.lang.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, java.lang.String modifier, java.lang.String build)
Creates a new version numberAppVersion(int major, int minor, int patch, java.lang.String modifier)
Creates a new major.minor.patch-modifier version number, e.g.1.0.1-SNAPSHOT.AppVersion(int major, int minor, java.lang.String modifier)
Creates a new major.minor-modifier version number, e.g.1.0-beta1.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(AppVersion other)
Compares two version numbers according to their major, minor, patch and milestone version numbers, ordering from oldest to newest version.boolean
equals(java.lang.Object other)
Check if two versions are exactly equal, modifier is case insensitive.int
getMajor()
Gets the version's major version number.int
getMilestone()
Get the milestone numberint
getMinor()
Gets the version's minor version number.java.lang.String
getModifier()
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
parse(java.lang.String versionString)
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(java.lang.String modifier)
Set the version's release modifier part.void
setPatch(int micro)
Sets the version's micro version / patch level number.java.lang.String
toString()
Returns the string represention of this version.
-
-
-
Field Detail
-
VERSION_REGEX
private static final java.util.regex.Pattern VERSION_REGEX
-
major
private int major
The version's major version number.
-
minor
private int minor
The version's minor version number.
-
patch
private int patch
The version's patch version number, if any.
-
milestone
private int milestone
The version's milestone number, if any.
-
modifier
private java.lang.String modifier
The version's modifier, if any.
-
build
private final java.lang.String build
The version's build, if any.
-
-
Constructor Detail
-
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
public AppVersion(int major, int minor, java.lang.String modifier)
Creates a new major.minor-modifier version number, e.g.1.0-beta1.- Parameters:
major
- major numberminor
- minor numbermodifier
- additional string
-
AppVersion
public AppVersion(int major, int minor, int patch, java.lang.String modifier)
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
public AppVersion(int major, int minor, int patch, int milestone, java.lang.String modifier)
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
public AppVersion(int major, int minor, int patch, int milestone, java.lang.String modifier, java.lang.String build)
Creates a new version number- Parameters:
major
- major numberminor
- minor numberpatch
- patch numbermilestone
- milestone numbermodifier
- additional stringbuild
- build string
-
-
Method Detail
-
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
public java.lang.String getModifier()
Gets the version's release modifier part.- Returns:
- modifier string
-
setModifier
public void setModifier(java.lang.String modifier)
Set the version's release modifier part.- Parameters:
modifier
- modifier string
-
equals
public boolean equals(java.lang.Object other)
Check if two versions are exactly equal, modifier is case insensitive.- Overrides:
equals
in classjava.lang.Object
- Parameters:
other
- second object- Returns:
- true if equal
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
olderThan
public boolean olderThan(AppVersion other)
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
public boolean newerThan(AppVersion other)
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
public int compareTo(AppVersion other)
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 interfacejava.lang.Comparable<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
public static AppVersion parse(java.lang.String versionString)
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:
java.lang.NumberFormatException
- If versionString could not be parsed to a version.
-
toString
public java.lang.String toString()
Returns the string represention of this version.- Overrides:
toString
in classjava.lang.Object
-
-