Closed SebastienDorgan closed 1 year ago
I found that I can use the MultiplyConverter class reading https://schneide.blog/tag/indriya/. Maybe the documentation of the Unit transform method should be updated
Thanks for the blog link!
I'm sure you figured this out already, what does work with Indriya:
import tech.units.indriya.AbstractUnit;
import tech.units.indriya.function.LogConverter;
import tech.units.indriya.function.MultiplyConverter;
//...
Unit<Dimensionless> DECIBEL = AbstractUnit.ONE.transform(
new LogConverter(10)
.inverse()
.concatenate(
MultiplyConverter.ofRational(1, 10)));
All 3 imported classes are specific to Indriya (the reference implementation). In other words the example above is specific to Indriya. Perhaps updating the javadoc in unit-api for javax.measure.Unit.transform(UnitConverter)
with a hint that the provided example there is just to make a point but depends on the actual implementation one is using would help. Though not sure whether worth the effort.
Thank you for your answer
@SebastienDorgan did the answer satisfy you and we may close this question?
Closing this based on the remark of May 30.
Hi, I use version 2.1.3 for indriya. I would like to create a DECIBEL unit as documented in the transform method of the Unit class. Unit DECIBEL = Unit.ONE.transform(
new LogConverter(10).inverse().concatenate(
new RationalConverter(1, 10)));
Unfortunately I do not found a public constructor or a static 'of' method that would allow me to to create a RationalConverter.
Can you help me?