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
Support parsing localized strings with DecimalType, PercentType and QuantityType #2365
Conversation
655c3b4
to
41a1bfa
Compare
…uantityType Adds constructors with a Locale parameter for parsing localized string to DecimalType, PercentType and QuantityType. This allows for parsing locale specific group and decimal seperators in strings. Also fixes: * IllegalArgumentException not being thrown if numbers in strings are only partially parsed as QuantityType * MeasurementParseException not caught and rethrown as IllegalArgumentException Several new unit tests cover the new functionality and fixed regressions. Signed-off-by: Wouter Born <github@maindrain.net>
41a1bfa
to
44de941
Compare
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.
lgtm, thanks!
Seems like some add-ons expect different exceptions to be thrown for illegal arguments since some tests now fail: https://ci.openhab.org/job/PR-openHAB-Addons/4221/#showFailuresLink IMHO it is better to always throw the same exception (IllegalArgumentException, new behavior) instead just throwing whatever runtime exception is thrown by the underlying implementations (NumberFormatException, MeasurementParseException, etc.). WDYT @openhab/core-maintainers? |
Throwing a
For the |
Besides that, the |
…uantityType (openhab#2365) Adds constructors with a Locale parameter for parsing localized string to DecimalType, PercentType and QuantityType. This allows for parsing locale specific group and decimal seperators in strings. Also fixes: * IllegalArgumentException not being thrown if numbers in strings are only partially parsed as QuantityType * MeasurementParseException not caught and rethrown as IllegalArgumentException Several new unit tests cover the new functionality and fixed regressions. Signed-off-by: Wouter Born <github@maindrain.net>
…uantityType (openhab#2365) Adds constructors with a Locale parameter for parsing localized string to DecimalType, PercentType and QuantityType. This allows for parsing locale specific group and decimal seperators in strings. Also fixes: * IllegalArgumentException not being thrown if numbers in strings are only partially parsed as QuantityType * MeasurementParseException not caught and rethrown as IllegalArgumentException Several new unit tests cover the new functionality and fixed regressions. Signed-off-by: Wouter Born <github@maindrain.net> GitOrigin-RevId: 3c30177
Adds constructors with a Locale parameter for parsing localized string to DecimalType, PercentType and QuantityType.
This allows for parsing locale specific group and decimal seperators in strings.
Also fixes:
Several new unit tests cover the new functionality and fixed regressions.
Further improves #2362