Closed wujiang1900 closed 3 months ago
The reason that I named the param as transformedUnit
is because my use cases as below:
public static final Unit<Temperature> RANKINE = addUnit(new TransformedUnit(FAHRENHEIT, new AddConverter(-459.67)), "Rankine", "R");
I made a new commit to change it to unit
as you suggested, so that it conforms the signature of other addUnit
methods.
Thanks for reviewing and the comments!
Hi, Werner, I've made the change as you suggested and addressed your comment. Could you review and merge the PR if everything looks ok?
Thank you!
Jiang
It would be really nice to have such feature on the library.
I am having the the same need to add new units of measurement to the collection. In this way also "getUnit" method can be used to access added custom units
In order for this project to be easily extendable, we can change addUnit methods to protected so that they can be accessed in client applications to add additional units to support the conversions of more unit types.
For the use cases, please see my program: https://github.com/wujiang1900/unit-converter. In particular, please refer to https://github.com/wujiang1900/unit-converter/blob/main/src/main/java/com/challenge/unitconverter/grader/javaximpl/AdditionalUnits.java and see how I'm able to add FAHRENHEIT and RANKINE and support their conversions with the existing CELSIUS unit.
I had to make the changes in this PR and built a new snapshot of indriya to be used in my application to make the above additional unit support working. Therefore please review my PR at your earliest conversion. The code changes below are tiny, but the impact to make indriya flexible and extendable is huge.
Thank you for reviewing!
This change is