Skip to content

Conversation

younies
Copy link
Member

@younies younies commented Jun 1, 2025

Description

This update introduces the followings

  • 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.
  • The internal measure units would be updated to include the conversion info.

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

  • Required: Issue filed: ICU-NNNNN
  • Required: The PR title must be prefixed with a JIRA Issue number. Example: "ICU-1234 Fix xyz"
  • Required: Each commit message must be prefixed with a JIRA Issue number. Example: "ICU-1234 Fix xyz"
  • Issue accepted (done by Technical Committee after discussion)
  • Tests included, if applicable
  • API docs and/or User Guide docs changed or added, if applicable

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.
Copy link
Member

@macchiati macchiati left a 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;

Copy link
Member

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.

Copy link
Member Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants