Interface SemanticVersion

All Superinterfaces:
Comparable<SemanticVersion>, Version

public interface SemanticVersion
extends Version, Comparable<SemanticVersion>
Represents a Sematic Version.

Compared to a regular Version, this type of version receives better support for version comparisons in dependency notations, and is preferred.

See Also:
Version
  • Field Details

  • Method Details

    • getVersionComponentCount

      int getVersionComponentCount()
      Returns the number of components in this version.

      For example, 1.3.x has 3 components.

      Returns:
      the number of components
    • getVersionComponent

      int getVersionComponent​(int pos)
      Returns the version component at pos.

      May return COMPONENT_WILDCARD to indicate a wildcard component.

      If the pos exceeds the number of components, returns COMPONENT_WILDCARD if the version has wildcard; otherwise returns 0.

      Parameters:
      pos - the position to check
      Returns:
      the version component
    • getPrereleaseKey

      Optional<String> getPrereleaseKey()
      Returns the prerelease key in the version notation.

      The prerelease key is indicated by a - before a + in the version notation.

      Returns:
      the optional prerelease key
    • getBuildKey

      Optional<String> getBuildKey()
      Returns the build key in the version notation.

      The build key is indicated by a + in the version notation.

      Returns:
      the optional build key
    • hasWildcard

      boolean hasWildcard()
      Returns if a wildcard notation is present in this version.

      A wildcard notation is a x, X, or * in the version string, such as 2.5.*.

      Returns:
      whether this version has a wildcard notation
    • compareTo

      int compareTo​(SemanticVersion o)

      Comparison of semantic versions is by the version components, from high to low; then it falls back to comparing the prerelease notations.

      Specified by:
      compareTo in interface Comparable<SemanticVersion>
      Parameters:
      o - the other version
      Returns:
      the result of comparison
    • parse

      static SemanticVersion parse​(String s) throws VersionParsingException
      Parses a semantic version from a string notation.
      Parameters:
      s - the string notation of the version
      Returns:
      the parsed version
      Throws:
      VersionParsingException - if a problem arises during version parsing