Package com.norconex.commons.lang.version

# Class SemanticVersionParser

java.lang.Object
com.norconex.commons.lang.version.SemanticVersionParser

public class SemanticVersionParser extends Object

Semantic version string parser. Default parser settings conform to https://semver.org/ specifications. Use available builder options for more lenient parsing.

## Max version length

The maximum string length supported by this parser is 255 characters. Longer strings will throw a `SemanticVersionParserException` except when `SemanticVersionParser.SemanticVersionParserBuilder.ignoreLeadingCharacters(boolean)` is `true`. In such case, it will try parsing longer strings, but will only consider the last 255 characters.

Since:
  3.0.0

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `SemanticVersionParser.SemanticVersionParserBuilder`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final SemanticVersionParser`
  `LENIENT`
  A relaxed parser with support for optional minor and patch numbers, ignoring leading characters, and ignoring the following suffix strings: `.jar`, `.zip`, `.exe`, `.gz`, `.tgz`, `.tar`, and `.tar.gz`,
  `static final SemanticVersionParser`
  `STRICT`
  Default parser settings, using strict adherence to SemVer specifications.
  `static final SemanticVersionParser`
  `TAG`
  Same as `STRICT` except for ignoring non-numeric leading characters before the version (e.g., `v1.2.3`).

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static SemanticVersionParser.SemanticVersionParserBuilder`
  `builder()`
  `protected boolean`
  `canEqual(Object other)`
  `boolean`
  `equals(Object o)`
  `int`
  `hashCode()`
  `SemanticVersion`
  `parse(String version)`
  Parses a semantic version string.

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### STRICT

    public static final SemanticVersionParser STRICT
    Default parser settings, using strict adherence to SemVer specifications.

  - ### LENIENT

    public static final SemanticVersionParser LENIENT
    A relaxed parser with support for optional minor and patch numbers, ignoring leading characters, and ignoring the following suffix strings: `.jar`, `.zip`, `.exe`, `.gz`, `.tgz`, `.tar`, and `.tar.gz`,

  - ### TAG

    public static final SemanticVersionParser TAG
    Same as `STRICT` except for ignoring non-numeric leading characters before the version (e.g., `v1.2.3`).

- ## Method Details

  - ### parse

    public SemanticVersion parse(String version)
    Parses a semantic version string.
    Parameters:
      `version` - the string to parse
    Returns:
      a semantic version instance
    Throws:
      `SemanticVersionParserException` - if the version can't be parsed.

  - ### builder

    public static SemanticVersionParser.SemanticVersionParserBuilder builder()

  - ### equals

    public boolean equals(Object o)
    Overrides:
      `equals` in class `Object`

  - ### canEqual

    protected boolean canEqual(Object other)

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`