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

model.CountryBSONCodec.kt Maven / Gradle / Ivy

package com.github.fluidsonic.baku

import org.bson.BsonReader
import org.bson.BsonWriter


internal object CountryBSONCodec : AbstractBSONCodec() {

	override fun BsonReader.decode(context: BSONCodingContext) =
		readString().let { code ->
			Country.byCode(code) ?: throw BSONException("Invalid country code '$code'")
		}


	override fun BsonWriter.encode(value: Country, context: BSONCodingContext) {
		writeString(value.code)
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy