Package org.pkl.core
Class Version
java.lang.Object
org.pkl.core.Version
- All Implemented Interfaces:
Comparable<Version>
A semantic version.
This class guarantees that valid semantic version numbers are handled correctly, but does not guarantee that invalid semantic version numbers are rejected.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Comparator<Version> Returns a comparator for semantic versions.intCompares this version to the given version according to semantic versioning rules.booleanTells if this version is equal toobjaccording to semantic versioning rules.getBuild()Returns the build metadata (if any).intgetMajor()Returns the major version.intgetMinor()Returns the minor version.intgetPatch()Returns the patch version.Returns the pre-release version (if any).inthashCode()booleanisNormal()Tells if this version has no pre-release version or build metadata.booleanisStable()Tells if this version has a non-zero major version and no pre-release version.static VersionParses the given string as a semantic version number.parseOrNull(String version) Parses the given string as a semantic version number.toNormal()Strips any pre-release version and build metadata from this version.toString()Returns a copy of this version with the given build metadata.withMajor(int major) Returns a copy of this version with the given major version.withMinor(int minor) Returns a copy of this version with the given minor version.withPatch(int patch) Returns a copy of this version with the given patch version.withPreRelease(@Nullable String preRelease) Returns a copy of this version with the given pre-release version.
-
Constructor Details
-
Method Details
-
parse
Parses the given string as a semantic version number.Throws
IllegalArgumentExceptionif the given string could not be parsed as a semantic version number or is too large to fit into aVersion. -
parseOrNull
Parses the given string as a semantic version number.Returns
nullif the given string could not be parsed as a semantic version number or is too large to fit into aVersion. -
comparator
Returns a comparator for semantic versions. -
getMajor
public int getMajor()Returns the major version. -
withMajor
Returns a copy of this version with the given major version. -
getMinor
public int getMinor()Returns the minor version. -
withMinor
Returns a copy of this version with the given minor version. -
getPatch
public int getPatch()Returns the patch version. -
withPatch
Returns a copy of this version with the given patch version. -
getPreRelease
Returns the pre-release version (if any). -
withPreRelease
Returns a copy of this version with the given pre-release version. -
getBuild
Returns the build metadata (if any). -
withBuild
Returns a copy of this version with the given build metadata. -
isNormal
public boolean isNormal()Tells if this version has no pre-release version or build metadata. -
isStable
public boolean isStable()Tells if this version has a non-zero major version and no pre-release version. -
toNormal
Strips any pre-release version and build metadata from this version. -
compareTo
Compares this version to the given version according to semantic versioning rules.- Specified by:
compareToin interfaceComparable<Version>
-
equals
Tells if this version is equal toobjaccording to semantic versioning rules. -
hashCode
public int hashCode() -
toString
-