inc

fun Version.inc(by: Inc, preRelease: String? = null): Version(source)

Increases the version by its Inc.MAJOR, Inc.MINOR, Inc.PATCH, or Inc.PRE_RELEASE segment.

Inc.MAJOR ->nextMajor

Inc.MINOR ->nextMinor

Inc.PATCH ->nextPatch

Inc.PRE_RELEASE ->nextPreRelease

Returns a new version while the original remains unchanged.

Samples

import io.github.z4kn4fein.semver.Inc
import io.github.z4kn4fein.semver.LooseVersionSerializer
import io.github.z4kn4fein.semver.Version
import io.github.z4kn4fein.semver.VersionSerializer
import io.github.z4kn4fein.semver.constraints.toConstraint
import io.github.z4kn4fein.semver.inc
import io.github.z4kn4fein.semver.nextMajor
import io.github.z4kn4fein.semver.nextMinor
import io.github.z4kn4fein.semver.nextPatch
import io.github.z4kn4fein.semver.nextPreRelease
import io.github.z4kn4fein.semver.satisfies
import io.github.z4kn4fein.semver.satisfiesAll
import io.github.z4kn4fein.semver.satisfiesAny
import io.github.z4kn4fein.semver.toVersion
import io.github.z4kn4fein.semver.toVersionOrNull
import io.github.z4kn4fein.semver.withoutSuffixes
import kotlinx.serialization.json.Json

fun main() { 
   //sampleStart 
   val version = "1.0.0-alpha.1".toVersion()
println(version.inc(by = Inc.MAJOR))
println(version.inc(by = Inc.MINOR))
println(version.inc(by = Inc.PATCH))
println(version.inc(by = Inc.PRE_RELEASE))

println(version.inc(by = Inc.MAJOR, preRelease = ""))
println(version.inc(by = Inc.MINOR, preRelease = "beta")) 
   //sampleEnd
}