Package io.github.z4kn4fein.semver

Types

Link copied to clipboard
class Version : Comparable<Version>

This class describes a semantic version and related operations.

Link copied to clipboard
class VersionFormatException(message: String) : Exception

Version throws this exception when the parsing fails due to an invalid format.

Functions

Link copied to clipboard
fun Version.copy(major: Int = this.major, minor: Int = this.minor, patch: Int = this.patch, preRelease: String? = this.preRelease, buildMetadata: String? = this.buildMetadata): Version

Constructs a copy of the Version. The copied object's properties can be altered with the optional parameters.

Link copied to clipboard
fun Version.nextMajor(): Version

Increments the version by its MAJOR number. Returns a new version while the original remains unchanged.

Link copied to clipboard
fun Version.nextMinor(): Version

Increments the version by its MINOR number. Returns a new version while the original remains unchanged.

Link copied to clipboard
fun Version.nextPatch(): Version

Increments the version by its PATCH number. Returns a new version while the original remains unchanged.

Link copied to clipboard
fun Version.nextPreRelease(): Version

Increments the version by its PRE-RELEASE part. Returns a new version while the original remains unchanged.

Link copied to clipboard
fun String.toVersion(): Version

Parses the string as a Version and returns the result or throws a VersionFormatException if the string is not a valid representation of a semantic version.

Link copied to clipboard
fun String.toVersionOrNull(): Version?

Parses the string as a Version and returns the result or null if the string is not a valid representation of a semantic version.