vdurmont/semver4j

[Feature Request] Add SemverType.FREESTYLE

Opened this issue · 0 comments

I would like to use Semver library to sort versions that does not necessariy meet STRICT or LOOSE requirement.
Here my exemplary set of versions: "v1", "2", "1.1", "5.0.3.GA", "unknown", "anyString-that-cannotBeParsedAsVersion", etc.
Currently if I use any of existing SemverTypes it throws exception in constructor (e.g. for "unknown").

I would like to have new SemverType.FREESTYLE (the name can be changed if you find better one) so that it can parse versions like LOOSE (or event NPM) but those which could not be parsed (e.g. "unknown") would be also constructed and put in the end while sorting (compareTo() method).

So if i have a list of Semver 'versions' objects which values: "v1", "2", "1.1", "5.0.3.GA", "unknown"
The Collections.sort(versions) would give one of the following (please choose which would be easier/better to implement):

  • "1.1", "2". "5.0.3.GA", "unknown", "v1" (if "v1" would not be parsed as a valid version)
  • "v1", "1.1", "2". "5.0.3.GA", "unknown" (if "v1" would be parsed as a valid version)
  • "1.1", "2". "5.0.3.GA", "v1", "unknown" (if "v1" would be parsed as a valid version but ordered after pure numeric versions)