public interface SemanticVersion extends Version, Comparable<SemanticVersion>
Compared to a regular Version, this type of version receives better support
for version comparisons in dependency notations, and is preferred.
Version| Modifier and Type | Field and Description |
|---|---|
static int |
COMPONENT_WILDCARD
The value of version component that indicates
a wildcard.
|
| Modifier and Type | Method and Description |
|---|---|
default int |
compareTo(SemanticVersion o) |
Optional<String> |
getBuildKey()
Returns the build key in the version notation.
|
Optional<String> |
getPrereleaseKey()
Returns the prerelease key in the version notation.
|
int |
getVersionComponent(int pos)
Returns the version component at
pos. |
int |
getVersionComponentCount()
Returns the number of components in this version.
|
boolean |
hasWildcard()
Returns if a wildcard notation is present in this version.
|
static SemanticVersion |
parse(String s)
Parses a semantic version from a string notation.
|
getFriendlyStringstatic final int COMPONENT_WILDCARD
int getVersionComponentCount()
For example, 1.3.x has 3 components.
int getVersionComponent(int pos)
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.
pos - the position to checkOptional<String> getPrereleaseKey()
The prerelease key is indicated by a - before a + in
the version notation.
Optional<String> getBuildKey()
The build key is indicated by a + in the version notation.
boolean hasWildcard()
A wildcard notation is a x, X, or * in the version string,
such as 2.5.*.
default 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.
compareTo in interface Comparable<SemanticVersion>o - the other versionstatic SemanticVersion parse(String s) throws VersionParsingException
parse in interface Versions - the string notation of the versionVersionParsingException - if a problem arises during version parsing