Package com.helixframework.semver
Class Version
java.lang.Object
com.helixframework.semver.Version
- All Implemented Interfaces:
Serializable,Comparable<Version>
Utility for parsing and comparing semantic versions.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionVersion(int major) Creates a new instance ofVersion.Version(int... parts) Creates a new instance ofVersion.Version(int major, int minor) Creates a new instance ofVersion.Version(int major, int minor, int patch) Creates a new instance ofVersion.Version(int major, int minor, int patch, int build) Creates a new instance ofVersion. -
Method Summary
Modifier and TypeMethodDescriptionintintbooleanintgetBuild()Returns the build number.intgetMajor()Returns the major version.intgetMinor()Returns the minor version.intgetPatch()Returns the patch version.inthashCode()booleanisGreaterThan(Version version) Checks if this version is greater than the supplied version.booleanisGreaterThanOrEqualTo(Version version) Checks if this version is greater than or equal to the supplied version.booleanisLessThan(Version version) Checks if this version is less than the supplied version.booleanisLessThanOrEqualTo(Version version) Checks if this version is less than or equal to the supplied version.booleanisSameMajorVersion(Version version) Checks if this version has the same major version as the supplied version.booleanisSameMinorVersion(Version version) Checks if this version has the same major and minor version as the supplied version.booleanisSamePatchVersion(Version version) Checks if this version has the same major, minor, and patch version as the supplied version.Gets the next build number version.Gets the next major version.Gets the next minor version.Gets the next patch version.static VersionParses the given string representation of a version into aVersionobject.toString()
-
Constructor Details
-
Version
public Version(int major) Creates a new instance ofVersion.- Parameters:
major- major version
-
Version
public Version(int major, int minor) Creates a new instance ofVersion.- Parameters:
major- major versionminor- minor version
-
Version
public Version(int major, int minor, int patch) Creates a new instance ofVersion.- Parameters:
major- major versionminor- minor versionpatch- patch version
-
Version
public Version(int major, int minor, int patch, int build) Creates a new instance ofVersion.- Parameters:
major- major versionminor- minor versionpatch- patch versionbuild- build version
-
Version
public Version(int... parts) Creates a new instance ofVersion.- Parameters:
parts- array of version parts: major, minor, patch, build
-
-
Method Details
-
parse
Parses the given string representation of a version into aVersionobject.- Parameters:
version- must not be null or empty- Returns:
- a
Version
-
isGreaterThan
Checks if this version is greater than the supplied version.- Parameters:
version- version- Returns:
trueif greater than; otherwisefalse
-
isGreaterThanOrEqualTo
Checks if this version is greater than or equal to the supplied version.- Parameters:
version- version- Returns:
trueif greater than or equal to; otherwisefalse
-
isLessThan
Checks if this version is less than the supplied version.- Parameters:
version- version- Returns:
trueif less than; otherwisefalse
-
isLessThanOrEqualTo
Checks if this version is less than or equal to the supplied version.- Parameters:
version- version- Returns:
trueif less than or equal to; otherwisefalse
-
isSameMajorVersion
Checks if this version has the same major version as the supplied version.- Parameters:
version- version- Returns:
trueif same major version; otherwisefalse
-
isSameMinorVersion
Checks if this version has the same major and minor version as the supplied version.- Parameters:
version- version- Returns:
trueif same major and minor version; otherwisefalse
-
isSamePatchVersion
Checks if this version has the same major, minor, and patch version as the supplied version.- Parameters:
version- version- Returns:
trueif same major, minor, and patch version; otherwisefalse
-
nextMajor
Gets the next major version.- Returns:
- next major
Version
-
nextMinor
Gets the next minor version.- Returns:
- next minor
Version
-
nextPatch
Gets the next patch version.- Returns:
- next patch
Version
-
nextBuild
Gets the next build number version.- Returns:
- next build number
Version
-
compareTo
- Specified by:
compareToin interfaceComparable<Version>
-
compareTo
-
getMajor
public int getMajor()Returns the major version.- Returns:
- major version
-
getMinor
public int getMinor()Returns the minor version.- Returns:
- minor version
-
getPatch
public int getPatch()Returns the patch version.- Returns:
- patch version
-
getBuild
public int getBuild()Returns the build number.- Returns:
- build number
-
equals
-
hashCode
public int hashCode() -
toString
-