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

commonMain.at.asitplus.wallet.mdl.IsoSexEnumSerializer.kt Maven / Gradle / Ivy

There is a newer version: 1.1.1
Show newest version
package at.asitplus.wallet.mdl

import kotlinx.serialization.KSerializer
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder

object IsoSexEnumSerializer : KSerializer {

    override val descriptor: SerialDescriptor =
        PrimitiveSerialDescriptor("IsoSexEnum?", PrimitiveKind.STRING)

    override fun serialize(encoder: Encoder, value: IsoSexEnum?) {
        value?.let { encoder.encodeInt(it.code) }
    }

    override fun deserialize(decoder: Decoder): IsoSexEnum? {
        return IsoSexEnum.parseCode(decoder.decodeInt())
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy