All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pcimcioch.gitlabci.dsl.serializer.StringRepresentationSerializer.kt Maven / Gradle / Ivy

There is a newer version: 1.6.0
Show newest version
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)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy