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

Implement equals and hashCode in model classes across the entire driver

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: API
    • None

      At present equals() is inherited from Object, thus comparing two CreateIndexOptions is not straightforward as the inherited method does not actually compare the content of the objects:

              CreateIndexOptions io = new CreateIndexOptions();
              CreateIndexOptions io2 = new CreateIndexOptions();
              boolean result = io.equals(io2);
              boolean result2 = io.equals(io);
              System.out.println(result);
              System.out.println(result2);
              System.out.println(io.toString());
              System.out.println(io2.toString());
      

      The above yields:

      false
      true
      CreateIndexOptions{maxTimeMS=0, commitQuorum=null}
      CreateIndexOptions{maxTimeMS=0, commitQuorum=null}
      

      The same goes for nearly every model class in the driver.

            Assignee:
            Unassigned Unassigned
            Reporter:
            dmitry.ryabtsev@mongodb.com Dmitry Ryabtsev
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: