[JAVA-4826] BsonRepresentation annotation to be used with generics Lists & Maps Created: 02/Dec/22  Updated: 09/Oct/23

Status: Backlog
Project: Java Driver
Component/s: POJO
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Andrea Santi Assignee: Unassigned
Resolution: Unresolved Votes: 7
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Quarter: FY24Q4
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

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

 

 

 



 Comments   
Comment by Ashni Mehta [ 12/Dec/22 ]

Hi Andrea, thank you for filing this feature request, and for the feedback on https://jira.mongodb.org/browse/JAVA-3677.

We'll be taking this into consideration for an upcoming release. However, it may be some time before we are able to get to it due to existing commitments and priorities.

We are happy to accept contributions to help improve the driver, if you'd be interested in submitting a pull request and possibly collaborating on some of this work.

Generated at Thu Feb 08 09:03:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.