Closed andi-huber closed 4 years ago
API extension? I'm not sure, if that's required, but refining some implementation details, that is likely and possible.
There should be no real major API changes before another JSR some day in the future, only bug fixes via a MR. Improvements of Indriya that is another story, MixedRadix
/CompoundQuantity
are good examples, also the DimensionalModel
was never part of the API. And I cannot say, if they ever do. Some maybe, take Prefix
, others probably stay comfortably here.
Hmm... pretty slick. Adds a category to a unit, and if units have same dimension but different categories, then isCompatible() returns false. The dimensionless unit still obeys principle of least surprise in that mySteradian.multiply(meters.pow(2)).getDimension() = "Area'.
Only challenge is it doesn't solve the problem of people using degrees for radians by accident and blowing up the rocket, but it certainly solves the dimensional analysis problem.
Thoughts on this idea of 'categories' for units:
1) Indriya (RI) provides all predefined Units
without associating any categories to these. (STERADIAN could be the exception.)
2) Declaring Units
with associated categories is up to the RI user and allows for context specific refinement of the implemented 'dimensional analysis'.
3) Associating categories with Units
creates new instances of Units
.
4) Do Units
with associated categories need a new (textual output) format?
5) Quantity addition/subtraction must throw if the operands' Units
are not compatible.
6) Quantity multiplication is allowed for operands of incompatible units. There seems to be evidence [1], that multiplication/division of Units
of different categories does work consistently, if we treat categories like (pseudo-) dimensions.
7) We could probably provide this new functionality for RI without having to touch the API.
[1] https://en.wikipedia.org/wiki/Dimensional_analysis#Extensions
Addressing the discussion in #257, I've added 3 test-cases, where the last one includes a vague proposal for an API extension.
This change is