[JAVA-3320] Add a way to allow same annotation on field and its accessor methods Created: 12/Jun/19  Updated: 28/Oct/23  Resolved: 05/Aug/19

Status: Closed
Project: Java Driver
Component/s: POJO
Affects Version/s: 3.5.0, 3.10.2
Fix Version/s: 3.11.0

Type: Improvement Priority: Major - P3
Reporter: Aarjav Patel Assignee: John Stewart (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

We have a class like this:

public class Foo { 
   @BsonId 
   public ObjectId id;
 
   @Nullable 
   private String optionalString;
 
   @Nullable
   public String getOptionalString() {
       return optionalString; 
   } 
}

 

For the above class,  when building the class model, an exception in thrown in PropertyMetadata class, stating that the `Nullable` annotation already exists. The reason for throwing the exception in discussed in link below:

https://github.com/mongodb/mongo-java-driver/pull/405#discussion_r128712243

Would it be possible to allow above use case somehow? Simplest solution I can think of is to allow the same annotation if it equals the existing one.



 Comments   
Comment by Githook User [ 05/Aug/19 ]

Author:

{'name': 'John Stewart', 'username': 'jstewart-mongo', 'email': 'john.stewart@mongodb.com'}

Message: Allow duplicate annotations in classes for use in POJO codec

JAVA-3320
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/b73525659ef72a45b632efabb152b8466849e2f7

Generated at Thu Feb 08 08:59:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.