-
Type: Improvement
-
Resolution: Unresolved
-
Priority: 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