Constraint
This class describes a semantic version constraint. It provides ability to verify whether a version satisfies one or more conditions within a constraint.
Samples
import io.github.z4kn4fein.semver.constraints.Constraint
import io.github.z4kn4fein.semver.constraints.ConstraintSerializer
import io.github.z4kn4fein.semver.constraints.satisfiedBy
import io.github.z4kn4fein.semver.constraints.satisfiedByAll
import io.github.z4kn4fein.semver.constraints.satisfiedByAny
import io.github.z4kn4fein.semver.constraints.toConstraint
import io.github.z4kn4fein.semver.constraints.toConstraintOrNull
import io.github.z4kn4fein.semver.toVersion
import kotlinx.serialization.json.Json
fun main() {
//sampleStart
val constraints =
listOf(
"1.0.0",
"!=1.0.0",
"~1.0",
"^1.x",
"1.1.0 - 1.2.*",
">=1.1.0 <3 || =0.1 || 5 - 6",
"v1",
"v3 - v4",
">=v2.3",
)
constraints.forEach { println("[$it]: [${it.toConstraint()}]") }
//sampleEnd
}
Types
Link copied to clipboard
object Companion
Companion object of Constraint.
Functions
Link copied to clipboard
Determines whether a Constraint is satisfied by a Version or not.
Link copied to clipboard
Determines whether a Constraint is satisfied by a Version or not.
Link copied to clipboard
Determines whether a Constraint is satisfied by each Version in a collection or not.
Link copied to clipboard
Determines whether a Constraint is satisfied by at least one Version in a collection or not.