findCodecForType

fun <T> findCodecForType(type: KType): Codec<T>(source)

Returns the instance of Codec (from the official MongoDB driver) that is used to encode or decode the given type.

If type and T do not match, the behavior is unspecified. Prefer using the no-argument of this method.

See also

The codec registry used by this BSON factory.

Throws

If no matching codec is found for the given type.


inline fun <T> findCodecForType(): Codec<T>(source)

Returns the instance of Codec (from the official MongoDB driver) that is used to encode or decode the given type T.

Example

val client = MongoClient.create("mongodb://mongo:27017")
val factory = BsonFactory(client.codecRegistry)

val codec = factory.findCodecForType<String>()

See also

The codec registry used by this BSON factory.

Throws

If no matching codec is found for the given type.