Package org.savantbuild.domain
Class Version
java.lang.Object
org.savantbuild.domain.Version
- All Implemented Interfaces:
Comparable<Version>
This class models a simple three number version as well as any free form version String. It has two modes of
operation, strict and relaxed.
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classModels the PreRelease portion of the Semantic Version String. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringfinal intfinal Stringfinal intfinal intfinal Version.PreRelease -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of the comparison between this Version and the given Object.booleanCompares the given Object with this Version for equality.intgetMajor()intgetMinor()intgetPatch()inthashCode()booleanisCompatibleWith(Version other) Performs semantic version compatibility checking.booleanbooleanisMajor()booleanisMinor()booleanisPatch()booleantoString()Converts the version number to a string suitable for debugging.
-
Field Details
-
INTEGRATION
- See Also:
-
major
public final int major -
metaData
-
minor
public final int minor -
patch
public final int patch -
preRelease
-
-
Constructor Details
-
Version
public Version() -
Version
Constructs a version with the given major, minor and patch version numbers.- Parameters:
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.
-
Version
Constructs a version by parsing the given String.- Parameters:
version- The version String to parse.- Throws:
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).
-
-
Method Details
-
compareTo
Returns the value of the comparison between this Version and the given Object. This throws an exception if the object given is not a Version.- Specified by:
compareToin interfaceComparable<Version>- Parameters:
other- The other Object to compare against.- Returns:
- A positive integer if this Version is larger than the given version. Zero if the given Version is the exact same as this Version. A negative integer is this Version is smaller that the given Version.
-
equals
Compares the given Object with this Version for equality. -
getMajor
public int getMajor() -
getMetaData
-
getMinor
public int getMinor() -
getPatch
public int getPatch() -
getPreRelease
-
hashCode
public int hashCode() -
isCompatibleWith
Performs semantic version compatibility checking. If this version is on the 0.x line, than the other version has to be on the same minor line (e.g. 0.3 is not compatible with 0.4). Otherwise, the two versions have to be on the same major line (e.g. 1.0 is not compatible with 2.0).- Parameters:
other- The other version to check against.- Returns:
- True if the versions are compatible, false if they aren't.
-
isIntegration
public boolean isIntegration()- Returns:
- True if this Version is an integration, false for all other types of versions.
-
isMajor
public boolean isMajor()- Returns:
- True if this Version is a major, false for all other types of versions.
-
isMinor
public boolean isMinor()- Returns:
- True if this Version is a minor, false for all other types of versions.
-
isPatch
public boolean isPatch()- Returns:
- True if this Version is a patch, false for all other types of versions.
-
isPreRelease
public boolean isPreRelease()- Returns:
- True if this Version is a snapshot, false for all other types of versions.
-
toIntegrationVersion
-
toString
Converts the version number to a string suitable for debugging.
-