Motivation: JAVA-3677 Introduced the use of BsonRepresentation annotation in order to have clean PoJo. That was a nice improvement.
The current annotation cannot be used however in List & Maps: i.e. is not possible to have something like this:
List<@BsonRepresentation(BsonType.OBJECT_ID) String> Map<@BsonRepresentation(BsonType.OBJECT_ID) String, MyPojo>
This is mainly because the current annotation target is the following
@Target({FIELD,METHOD})
It would be nice to have also as target TYPE_USE (e.g. thishttps://javaee.github.io/javaee-spec/javadocs/index.html?javax/validation/constraints/package-summary.html annotation can be used in type arguments of List and Map.
In the C# driver this support is available: we have the DictionaryRepresentationhttps://mongodb.github.io/mongo-csharp-driver/1.11/serialization/ annotation