Add support for Compound Units
keilw opened this issue · 2 comments
JSR-275 included a CompoundUnit
, see http://grepcode.com/file/repo1.maven.org/maven2/net.java.dev.jsr-275/jsr-275/1.0-beta-2/javax/measure/unit/CompoundUnit.java
Via Unit.compound(Unit)
a chain of units could be created like "2 years and 3 months". In a similar way as JSR 310 https://docs.oracle.com/javase/8/docs/api/java/time/temporal/TemporalAmount.html allows for temporal amounts. Or the minor/major aspects of JSR 354.
Requires #17
This is related to unitsofmeasurement/indriya#17 in the RI.
For properly composing and decomposing compound quantities an approach very close to Wolfram's MixedUnit and a CompoundQuantity
(which is now however a true Quantity
implementation only preserving the parts under the hood, it plays the part of Wolfram's MixedMagnitude
) the most reliable way to realize unitsofmeasurement/indriya#97 involves adding a CompoundUnit
(we could also call it MixedUnit
, but both names feel OK) again. Since the API always had methods like alternate()
or transform()
for some particular implementing type and prefix()
was also recently added, it seems reasonable to also add compound()
to the Unit
API.