Litote / kmongo

[deprecated] KMongo - a Kotlin toolkit for Mongo
https://litote.org/kmongo/
Apache License 2.0
781 stars 74 forks source link

Added possibility to customize `ObjectMapper`'s `KotlinModule` #382

Closed slaha closed 2 years ago

slaha commented 2 years ago

This pull request adds possibility to customize the KotlinModule used in KMongo's ObjectMapper.

The purpose for this feature is to be able to enable KotlinModule's features that are disabled by default (eg. KotlinFeature.SingletonSupport).

zigzago commented 2 years ago

Thank you for the PR, it looks great @slaha!

But why duplicating the KotlinFeature list in KotlinModuleConfiguration instead of using a KotlinModule.Builder?

object KotlinModuleConfiguration {
 val moduleBuilder : KotlinModule.Builder = KotlinModule.Builder()
}

If jackson adds a new KotlinFeature, then with the KotlinModule.Builder version there is no need to modify KMongo to support this new feature ;)

What do you think?

slaha commented 2 years ago

You are right and it was actually my first idea how to do it. But problem with this approach is that module kmongo-shared does not depend on jackson-module-kotlin so there is no KotlinModule available. I was not sure if it is ok to add the dependency to kmongo-shared because there is not much dependencies in the module.

zigzago commented 2 years ago

I agree kmongo-shared may not depend on jackson-module-kotlin. I would move KotlinModuleConfiguration in KMongoConfiguraton file in kmongo-jackson-mapping module.

slaha commented 2 years ago

Updated the PR with proposed changes.

zigzago commented 2 years ago

Thank you!