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

dev.morphia.mapping.codec.ReadWritePropertyCodec.kt Maven / Gradle / Ivy

There is a newer version: 2.4.14
Show newest version
package dev.morphia.mapping.codec

import kotlin.properties.ReadWriteProperty
import org.bson.BsonReader
import org.bson.BsonWriter
import org.bson.codecs.Codec
import org.bson.codecs.DecoderContext
import org.bson.codecs.EncoderContext

@Suppress("UNCHECKED_CAST")
class ReadWritePropertyCodec(private val codec: Codec) : Codec {
    override fun getEncoderClass(): Class = ReadWriteProperty::class.java as Class

    override fun encode(writer: BsonWriter, value: Any, context: EncoderContext) {
        context.encodeWithChildContext(codec, writer, value)
    }

    override fun decode(reader: BsonReader, context: DecoderContext): Any? {
        return codec.decode(reader, context)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy