pcimcioch.gitlabci.dsl.serializer.StringRepresentationSerializer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gitlab-ci-kotlin-dsl Show documentation
Show all versions of gitlab-ci-kotlin-dsl Show documentation
Library providing Kotlin DSL to configure GitlabCI file
package pcimcioch.gitlabci.dsl.serializer
import kotlinx.serialization.Decoder
import kotlinx.serialization.Encoder
import kotlinx.serialization.KSerializer
import kotlinx.serialization.PrimitiveDescriptor
import kotlinx.serialization.PrimitiveKind
import kotlinx.serialization.SerialDescriptor
import pcimcioch.gitlabci.dsl.StringRepresentation
open class StringRepresentationSerializer(
val name: String
) : KSerializer {
override val descriptor: SerialDescriptor = PrimitiveDescriptor(name, PrimitiveKind.STRING)
override fun serialize(encoder: Encoder, value: T) {
encoder.encodeString(value.stringRepresentation)
}
override fun deserialize(decoder: Decoder): T {
throw IllegalStateException(descriptor.serialName)
}
}