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

de.miraculixx.mcommons.serializer.UUIDSerializer.kt Maven / Gradle / Ivy

There is a newer version: 1.0.1
Show newest version
@file:Suppress("unused")

package de.miraculixx.mcommons.serializer

import kotlinx.serialization.KSerializer
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import java.util.*

object UUIDSerializer : KSerializer {
    override val descriptor = PrimitiveSerialDescriptor("UUID", PrimitiveKind.STRING)

    override fun deserialize(decoder: Decoder): UUID {
        return UUID.fromString(decoder.decodeString())
    }

    override fun serialize(encoder: Encoder, value: UUID) {
        encoder.encodeString(value.toString())
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy