I’ve just finish the course and started writing code in a real project and am facing a small problem.
Let’s say I have a POJO with a property named “firstName” that I want to map to a Mongo property named “name1” (for sack of simplicity, they a both Strings). I know I could annotate the POJO’s property with @BsonProperty, but what if I can’t modify the POJO (third party lib). Is it feasible to do such mapping with a ClassModelBuilder and a PropertyModelBuilder for instance?
With the same restriction in mind, what happens if my POJO does not have a default constructor? Can I specify somewhere how to instantiate a POJO based on the database model (i.e retrieving one or two fields and passing them to a specific constructor)?
I know I could do both of these by registering a custom Codec with the CodeRegistries.fromCodecs(…) when building my CodecRegistry but if I do so, I need to map the whole POJO class (each and every property). I was maybe hoping to be able to a tinker with just one or two PropertyModelBuilder…