public class Version extends java.lang.Object implements java.lang.Comparable<Version>
When this class is constructed in it tries everything in its power to figure out what the heck a version string is and will only fail if the version string has two delimiters next to each other or begins/ends with a delimiter.
For the most part, this class correctly implements the Semantic Versioning system. This can be found here:
The only notable except to this scheme is that Savant supports integration builds, which are not released versions,
but are local versions to a single developer or a team. Integration builds are always denoted by an additional
version specifier of -{integration}
. For example, 1.0.0-{integration} denotes an integration build.
Modifier and Type | Class and Description |
---|---|
static class |
Version.PreRelease
Models the PreRelease portion of the Semantic Version String.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
INTEGRATION |
int |
major |
java.lang.String |
metaData |
int |
minor |
int |
patch |
Version.PreRelease |
preRelease |
Constructor and Description |
---|
Version(int major,
int minor,
int patch,
Version.PreRelease preRelease,
java.lang.String metaData)
Constructs a version with the given major, minor and patch version numbers.
|
Version(java.lang.String version)
Constructs a version by parsing the given String.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Version other)
Returns the value of the comparison between this Version and the given Object.
|
boolean |
equals(java.lang.Object o)
Compares the given Object with this Version for equality.
|
int |
hashCode() |
boolean |
isCompatibleWith(Version other)
Performs semantic version compatibility checking.
|
boolean |
isIntegration() |
boolean |
isMajor() |
boolean |
isMinor() |
boolean |
isPatch() |
boolean |
isPreRelease() |
Version |
toIntegrationVersion() |
java.lang.String |
toString()
Converts the version number to a string suitable for debugging.
|
public static final java.lang.String INTEGRATION
public final int major
public final java.lang.String metaData
public final int minor
public final int patch
public final Version.PreRelease preRelease
public Version(int major, int minor, int patch, Version.PreRelease preRelease, java.lang.String metaData)
major
- The major version number.minor
- The minor version number.patch
- The patch version number.preRelease
- The pre-release object.metaData
- The build meta data string.public Version(java.lang.String version)
version
- The version String to parse.VersionException
- If the string is incorrectly formatted and does not conform to the semantic versioning
scheme (starts with a delimiter (. or -), contains two delimiters in a row, doesn't have
proper pre-release or meta-data information).public int compareTo(Version other)
compareTo
in interface java.lang.Comparable<Version>
other
- The other Object to compare against.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- The object to compare with this Version for equality.public int hashCode()
hashCode
in class java.lang.Object
public boolean isCompatibleWith(Version other)
other
- The other version to check against.public boolean isIntegration()
public boolean isMajor()
public boolean isMinor()
public boolean isPatch()
public boolean isPreRelease()
public Version toIntegrationVersion()
public java.lang.String toString()
toString
in class java.lang.Object