-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
152 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
|
||
## verona | ||
|
||
The `verona` package provides types implementing the | ||
[Semantic Versioning](https://www.semver.org) specification. | ||
|
||
## Features | ||
|
||
* Types for representing versions and version ranges. | ||
* Parsers for version numbers and version ranges. | ||
* Written in pure Java 17. | ||
* [OSGi](https://www.osgi.org/) ready. | ||
* [JPMS](https://en.wikipedia.org/wiki/Java_Platform_Module_System) ready. | ||
* ISC license. | ||
* High-coverage automated test suite. | ||
|
||
## Description | ||
|
||
### Types | ||
|
||
The `verona` package contains types for representing versions and version | ||
ranges. | ||
|
||
``` | ||
assert Version.of(1, 0, 2).toString() == "1.0.2"; | ||
assert Version.of(2, 3, 1, "SNAPSHOT").toString() == "2.3.1-SNAPSHOT"; | ||
assert Version.of(3, 0, 0, "SNAPSHOT").toString() == "2.3.1-SNAPSHOT"; | ||
``` | ||
|
||
Values of type `Version` are comparable and are ordered such that version | ||
number components are treated as unsigned values and, for two versions `x` | ||
and `y`: | ||
|
||
``` | ||
Comparator.comparing(Version::major, COMPARE_UNSIGNED) | ||
.thenComparing(Version::minor, COMPARE_UNSIGNED) | ||
.thenComparing(Version::patch, COMPARE_UNSIGNED) | ||
.thenComparing(Version::qualifier, COMPARE_QUALIFIER) | ||
.compare(x, y); | ||
``` | ||
|
||
For a given version `x.y.z`, the version `x.y.z-q` is considered less than | ||
`x.y.z` for any `q`. | ||
|
||
### Parsing | ||
|
||
Version numbers can be parsed: | ||
|
||
``` | ||
assert VersionParser.parse("1.0.2").toString() == "1.0.2"; | ||
``` | ||
|
||
Parsing is strict by default. This means that exactly three version number | ||
components must be provided, along with an optional qualifier. Support is | ||
provided for _lax_ parsing that allows for missing components. For example: | ||
|
||
``` | ||
assert VersionParser.parse("1.2.0").toString() == "1.2.0"; | ||
|
||
VersionParser.parse("1.2"); // throws VersionException | ||
|
||
assert VersionParser.parseLax("1.2").toString() == "1.2.0"; | ||
``` | ||
|
||
Additional support is provided for [OSGi](https://www.osgi.org) version | ||
numbers where the qualifier is separated with a dot instead of a hyphen: | ||
|
||
``` | ||
assert VersionParser.parseOSGi("1.2.0.SNAPSHOT").toString() == "1.2.0-SNAPSHOT"; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters