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

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

The newest version!
package at.asitplus.wallet.cor

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