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.StringbuildThe version's build, if any.private intmajorThe version's major version number.private intmilestoneThe version's milestone number, if any.private intminorThe version's minor version number.private java.lang.StringmodifierThe version's modifier, if any.private intpatchThe version's patch version number, if any.private static java.util.regex.PatternVERSION_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 intcompareTo(AppVersion other)Compares two version numbers according to their major, minor, patch and milestone version numbers, ordering from oldest to newest version.booleanequals(java.lang.Object other)Check if two versions are exactly equal, modifier is case insensitive.intgetMajor()Gets the version's major version number.intgetMilestone()Get the milestone numberintgetMinor()Gets the version's minor version number.java.lang.StringgetModifier()Gets the version's release modifier part.intgetPatch()Gets the version's micro version / patch level number.inthashCode()booleannewerThan(AppVersion other)Checks if this version is newer than the specified version, according to the result ofcompareTo(AppVersion).booleanolderThan(AppVersion other)Checks if this version is older than the specified version, according to the result ofcompareTo(AppVersion).static AppVersionparse(java.lang.String versionString)Parses a version string into a Version object.voidsetMajor(int major)Set major numbervoidsetMilestone(int milestone)Set the milestone numbervoidsetMinor(int minor)Set minor numbervoidsetModifier(java.lang.String modifier)Set the version's release modifier part.voidsetPatch(int micro)Sets the version's micro version / patch level number.java.lang.StringtoString()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:
equalsin classjava.lang.Object- Parameters:
other- second object- Returns:
- true if equal
-
hashCode
public int hashCode()
- Overrides:
hashCodein 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:
compareToin 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:
toStringin classjava.lang.Object
-
-