Package net.fabricmc.loader.api
Interface SemanticVersion
- All Superinterfaces:
Comparable<SemanticVersion>
,Version
public interface SemanticVersion extends Version, Comparable<SemanticVersion>
Represents a Sematic Version.
Compared to a regular Version
, this type of version receives better support
for version comparisons in dependency notations, and is preferred.
- See Also:
Version
-
Field Summary
Fields Modifier and Type Field Description static int
COMPONENT_WILDCARD
The value of version component that indicates a wildcard. -
Method Summary
Modifier and Type Method Description 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 atpos
.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.Methods inherited from interface net.fabricmc.loader.api.Version
getFriendlyString
-
Field Details
-
COMPONENT_WILDCARD
static final int COMPONENT_WILDCARDThe value of version component that indicates a wildcard.- See Also:
- Constant Field Values
-
-
Method Details
-
getVersionComponentCount
int getVersionComponentCount()Returns the number of components in this version.For example,
1.3.x
has 3 components.- Returns:
- the number of components
-
getVersionComponent
int getVersionComponent(int pos)Returns the version component atpos
.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 returns0
.- Parameters:
pos
- the position to check- Returns:
- the version component
-
getPrereleaseKey
Returns the prerelease key in the version notation.The prerelease key is indicated by a
-
before a+
in the version notation.- Returns:
- the optional prerelease key
-
getBuildKey
Returns the build key in the version notation.The build key is indicated by a
+
in the version notation.- Returns:
- the optional build key
-
hasWildcard
boolean hasWildcard()Returns if a wildcard notation is present in this version.A wildcard notation is a
x
,X
, or*
in the version string, such as2.5.*
.- Returns:
- whether this version has a wildcard notation
-
compareTo
Comparison of semantic versions is by the version components, from high to low; then it falls back to comparing the prerelease notations.
- Specified by:
compareTo
in interfaceComparable<SemanticVersion>
- Parameters:
o
- the other version- Returns:
- the result of comparison
-
parse
Parses a semantic version from a string notation.- Parameters:
s
- the string notation of the version- Returns:
- the parsed version
- Throws:
VersionParsingException
- if a problem arises during version parsing
-