Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-3320

Add a way to allow same annotation on field and its accessor methods

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.11.0
    • Affects Version/s: 3.5.0, 3.10.2
    • Component/s: POJO
    • None

      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.

            Assignee:
            john.stewart@mongodb.com John Stewart (Inactive)
            Reporter:
            aarjav Aarjav Patel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: