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

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

package pcimcioch.gitlabci.dsl.serializer

import kotlinx.serialization.Decoder
import kotlinx.serialization.Encoder
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialDescriptor

open class ValueSerializer(
        private val valueSerializer: KSerializer,
        private val transform: (T) -> K
) : KSerializer {
    override val descriptor: SerialDescriptor = valueSerializer.descriptor

    override fun serialize(encoder: Encoder, value: T) {
        valueSerializer.serialize(encoder, transform.invoke(value))
    }

    override fun deserialize(decoder: Decoder): T {
        throw IllegalStateException(descriptor.serialName)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy