Class SemanticVersion
java.lang.Object
com.zetaplugins.zetacore.services.updatechecker.SemanticVersion
- All Implemented Interfaces:
Serializable,Comparable<SemanticVersion>
A class representing a semantic version (MAJOR.MINOR.PATCH) with optional label.
Supports parsing from string, comparison, and string representation.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSemanticVersion(int major, int minor, int patch) Constructs a SemanticVersion with major, minor and patch.SemanticVersion(int major, int minor, int patch, String label) Constructs a SemanticVersion with major, minor, patch and label.SemanticVersion(String versionString) Parses a semantic version string in the form "MAJOR.MINOR.PATCH" with an optional "-label" and optional leading "v" (or "V"), e.g. "1.2.3", "v1.2.3", "1.2.3-beta". -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(@NotNull SemanticVersion o) booleangetLabel()intgetMajor()intgetMinor()intgetPatch()inthashCode()booleanisGreaterThan(SemanticVersion other) Checks if this version is greater than the other version.booleanisLessThan(SemanticVersion other) Checks if this version is less than the other version.setMajor(int major) setMinor(int minor) setPatch(int patch) toString()
-
Constructor Details
-
SemanticVersion
public SemanticVersion(int major, int minor, int patch) Constructs a SemanticVersion with major, minor and patch.- Parameters:
major- The major version numberminor- The minor version numberpatch- The patch version number
-
SemanticVersion
Constructs a SemanticVersion with major, minor, patch and label.- Parameters:
major- The major version numberminor- The minor version numberpatch- The patch version numberlabel- The optional label (e.g. "beta", "rc1")
-
SemanticVersion
Parses a semantic version string in the form "MAJOR.MINOR.PATCH" with an optional "-label" and optional leading "v" (or "V"), e.g. "1.2.3", "v1.2.3", "1.2.3-beta". Throws IllegalArgumentException for null, empty, malformed, non-numeric, or negative parts.- Parameters:
versionString- The semantic version string to parse
-
-
Method Details
-
getMajor
public int getMajor() -
setMajor
-
getMinor
public int getMinor() -
setMinor
-
getPatch
public int getPatch() -
setPatch
-
getLabel
-
setLabel
-
isGreaterThan
Checks if this version is greater than the other version.- Parameters:
other- The other SemanticVersion to compare against- Returns:
- True if this version is greater than the other version, false otherwise
-
isLessThan
Checks if this version is less than the other version.- Parameters:
other- The other SemanticVersion to compare against- Returns:
- True if this version is less than the other version, false otherwise
-
compareTo
- Specified by:
compareToin interfaceComparable<SemanticVersion>
-
toString
-
equals
-
hashCode
public int hashCode()
-