Closed keilw closed 2 years ago
Looking at Map.of()
or List.of()
in 20 or more variations of arguments, all of those are merely convenience methods for the ImmutableCollections
. The method name is not self-descriptive because all of these should rather say ofImmutable()
or similar, instead of just of()
. That's bad naming and design and does not really add value over using the central Quantities
factory class.
If there was a way, Quantity
itself could tap into the SPI classes like QuantityFactory
and have a static Quantity.of(Number, Unit)
method, then that would make more sense in the API, but we'd have to find a generic way instead of having to pass the Class
of the quantity type.
Similar to the JDK
Map
orList
interfaces, we could add a static methodComparableQuantity.of()
to call directly on the interface. It may seem as a convenience method at first, but would allow to explore further pushing such methods up into the API, where this could work as well, but possibly not before a major release (to be explored, potentially in a MR2)