-
-
Notifications
You must be signed in to change notification settings - Fork 831
Add conversion support to MeasureUnit
#3512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add conversion support to MeasureUnit
#3512
Conversation
This update introduces the ConversionInfo class to the MeasureUnit, which encapsulates conversion details such as conversion rates and offsets to the base unit. Additionally, a new method, convertFrom, is implemented to facilitate conversions between MeasureUnits, ensuring proper handling of mixed units and convertibility checks. The constructor for MeasureUnit is also updated to accommodate the new conversion information. This enhancement aims to improve the functionality and usability of unit conversions within the ICU library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking pretty good
// If the conversionInfo is null, then the conversion info is not set for this | ||
// unit. | ||
private final ConversionInfo conversionInfo; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cache of measure units should use ConcurrentHashMaps, not synchronization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn’t fully understand the comment — could you please explain it in more detail?
Description
This update introduces the followings
ConversionInfo
class to the MeasureUnit, which encapsulates conversion details such as conversion rates and offsets to the base unit.convertFrom
, is implemented to facilitate conversions between MeasureUnits, ensuring proper handling of mixed units and convertibility checks.MeasureUnit
is also updated to accommodate the new conversion information.TODO: Please describe your changes here.
TODO: Please read the following on ICU Contributing, and then delete these instructions.
Thank you for your pull request!
TODO: Fill out the checklist below.
Checklist