Class SemanticVersion

java.lang.Object
com.zetaplugins.zetacore.services.updatechecker.SemanticVersion
All Implemented Interfaces:
Serializable, Comparable<SemanticVersion>

public class SemanticVersion extends Object implements Comparable<SemanticVersion>, Serializable
A class representing a semantic version (MAJOR.MINOR.PATCH) with optional label. Supports parsing from string, comparison, and string representation.
See Also:
  • Constructor Details

    • SemanticVersion

      public SemanticVersion(int major, int minor, int patch)
      Constructs a SemanticVersion with major, minor and patch.
      Parameters:
      major - The major version number
      minor - The minor version number
      patch - The patch version number
    • SemanticVersion

      public SemanticVersion(int major, int minor, int patch, String label)
      Constructs a SemanticVersion with major, minor, patch and label.
      Parameters:
      major - The major version number
      minor - The minor version number
      patch - The patch version number
      label - The optional label (e.g. "beta", "rc1")
    • SemanticVersion

      public 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". 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

      public SemanticVersion setMajor(int major)
    • getMinor

      public int getMinor()
    • setMinor

      public SemanticVersion setMinor(int minor)
    • getPatch

      public int getPatch()
    • setPatch

      public SemanticVersion setPatch(int patch)
    • getLabel

      public String getLabel()
    • setLabel

      public SemanticVersion setLabel(String label)
    • isGreaterThan

      public boolean isGreaterThan(SemanticVersion other)
      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

      public boolean isLessThan(SemanticVersion other)
      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

      public int compareTo(@NotNull @NotNull SemanticVersion o)
      Specified by:
      compareTo in interface Comparable<SemanticVersion>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object