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

Prepare BsonValue class hierarchy for migration to value classes

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: BSON
    • None
    • Java Drivers

      See https://openjdk.org/jeps/401. In particular, "concrete, non-final class will become final on migration". Unfortunately, we neglected to make classes like BsonDouble final. We should consider doing so, either as a breaking change in a minor release or in the next major release.

      The other change to consider is to add static valueOf factory method and possibly deprecate the constructors.

      Users of the class will be able to observe different == behavior after migration. If this is a concern, an ideal migration candidate might declare private constructors and provide a factory method that explicitly advertises the possibility of results that are == to a previous result. (See, for example, the Integer.valueOf factory method.)

      This would only be necessary for the scalar sub-classes of BsonValue, i.e.

      • BsonNull
      • BsonBoolean
      • BsonInt32
      • BsonInt64
      • BsonDouble
      • BsonDecimal128
      • BsonDateTime
      • BsonObjectId
      • BsonTimestamp
      • BsonMinKey
      • BsonMaxKey
      • BsonUndefined

      The classes that are not-final but should be are:

      • BsonDouble
      • BsonDateTime
      • BsonObjectId

            Assignee:
            Unassigned Unassigned
            Reporter:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: