ConstraintSerializer

object ConstraintSerializer : KSerializer<Constraint> (source)

Built-in kotlinx.serialization serializer that encodes and decodes Constraint as its string representation.

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 
   print(Json.encodeToString(ConstraintSerializer, ">1.2".toConstraint())) 
   //sampleEnd
}
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 decoded = Json.decodeFromString(ConstraintSerializer, "\">1.2\"")
print(decoded) 
   //sampleEnd
}

Properties

Link copied to clipboard
open override val descriptor: SerialDescriptor

Functions

Link copied to clipboard
open override fun deserialize(decoder: Decoder): Constraint
Link copied to clipboard
open override fun serialize(encoder: Encoder, value: Constraint)