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

commonMain.hassemble.values.Elevation.kt Maven / Gradle / Ivy

The newest version!
package hassemble.values

import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
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

@Serializable(Elevation.Companion::class)
data class Elevation(val value: Double) {
    override fun toString(): String = value.toString()

    companion object : KSerializer {
        override val descriptor: SerialDescriptor =
            PrimitiveSerialDescriptor("Elevation", PrimitiveKind.DOUBLE)
        override fun deserialize(decoder: Decoder) = Elevation(decoder.decodeDouble())
        override fun serialize(encoder: Encoder, value: Elevation) = encoder.encodeDouble(value.value)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy