This class represents a range of semamtic versions. The range can be inclusive or non-inclusive at both ends. Open ended ranges can be created by using an inclusive {@link Version#MIN} as the lower bound or an inclusive{@link Version#MAX} as the upper bound.
A version range can also be created from a string. The string is parsed according to the following rules:
- 1.2.3 — A specific version.
- >1.2.3 — Greater than a specific version.
- <1.2.3 — Less than a specific version.
- >=1.2.3 — Greater than or equal to a specific version.
- <=1.2.3 — Less than or equal to a specific version.
- >=1.0.0 <2.0.0 — Range of versions; both conditions must be satisfied. (This example would match 1.0.1 but not 2.0.1)
- 1.x — A semantic major version. (This example would match 1.0.1 but not 2.0.1, and is shorthand for >=1.0.0 <2.0.0-)
- 1.2.x — A semantic major & minor version. (This example would match 1.2.3 but not 1.3.0, and is shorthand for >=1.2.0 <1.3.0-)
- * — Matches any version
A range specifier starting with a tilde ~ character is matched against a version in the following fashion:
- The version must be at least as high as the range.
- The version must be less than the next minor revision above the range.
For example, the following are equivalent:
- ~1.2.3 = >=1.2.3 <1.3.0-)
- ~1.2 = >=1.2.0 <1.3.0-)
- ~1 = >=1.0.0 <1.1.0-)