entities.EntityIdBSONCodec.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of baku Show documentation
Show all versions of baku Show documentation
helps you focus your REST API back-end on the business logic
package com.github.fluidsonic.baku
import org.bson.BsonReader
import org.bson.BsonWriter
internal class EntityIdBSONCodec(
private val factory: EntityId.Factory
) : AbstractBSONCodec(valueClass = factory.idClass.java) {
override fun BsonReader.decode(context: BSONCodingContext) =
factory.run { readIdValue() }
override fun BsonWriter.encode(value: Id, context: BSONCodingContext) {
factory.run { writeIdValue(value) }
}
}