-
-
Notifications
You must be signed in to change notification settings - Fork 428
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
Add string utils to core #3738
Add string utils to core #3738
Conversation
Signed-off-by: lsiepel <[email protected]>
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.
It feels a bit like "yet another string utils library", but I can understand why you want to bring this into core.
It is up to core maintainers to decide if this should be included.
I have reviewed the PR from a code perspective and can give some technical input.
Overall two points: null handling is not yet consistent, and a few comments regarding performance.
bundles/org.openhab.core/src/main/java/org/openhab/core/util/StringUtils.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.core/src/main/java/org/openhab/core/util/StringUtils.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.core/src/main/java/org/openhab/core/util/StringUtils.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.core/src/main/java/org/openhab/core/util/StringUtils.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.core/src/main/java/org/openhab/core/util/StringUtils.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.core/src/main/java/org/openhab/core/util/StringUtils.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.core/src/main/java/org/openhab/core/util/StringUtils.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.core/src/main/java/org/openhab/core/util/StringUtils.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.core/src/main/java/org/openhab/core/util/StringUtils.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.core/src/test/java/org/openhab/core/util/StringUtilsTest.java
Show resolved
Hide resolved
Signed-off-by: lsiepel <[email protected]>
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.
Consistency regarding Null annotations to be discussed with maintainers. I follow your argumentation regarding the drop in replacement. Maybe a more consistent interface would be worth the effort and pay off in the future.
bundles/org.openhab.core/src/main/java/org/openhab/core/util/StringUtils.java
Outdated
Show resolved
Hide resolved
Signed-off-by: lsiepel <[email protected]>
I'm fine with adding those utils here - as long as we do not end up with a whole library in the end. 😆 @openhab/core-maintainers What's your position wrt this PR? |
Signed-off-by: Leo Siepel <[email protected]>
Both kai and holger suggested aligning the null handling, so i did. I hope we can get this merged so i can update the addon PR's to use this. |
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.
Fine. Just added a few findings, mainly related to the examples given in javadoc.
bundles/org.openhab.core/src/main/java/org/openhab/core/util/StringUtils.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.core/src/main/java/org/openhab/core/util/StringUtils.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.core/src/main/java/org/openhab/core/util/StringUtils.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.core/src/main/java/org/openhab/core/util/StringUtils.java
Show resolved
Hide resolved
bundles/org.openhab.core/src/main/java/org/openhab/core/util/StringUtils.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.core/src/main/java/org/openhab/core/util/StringUtils.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Leo Siepel <[email protected]>
Signed-off-by: Leo Siepel <[email protected]>
Signed-off-by: Leo Siepel <[email protected]>
…into core-utils
Signed-off-by: Leo Siepel <[email protected]>
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.
Thanks for implementing all the review comments!
My last point is about this:
I have the feeling that calling two methods capitalizeWords()
and capitalizAllWords()
is not right way. I assume that I would never remember correctly which one of them uses space or underscores as delimiter. It is also unexpected that both functions handle the remaining letters of the words differently (converting to lowercase or leaving as it is).
Though, I have no proposal for a better naming.
bundles/org.openhab.core/src/main/java/org/openhab/core/util/StringUtils.java
Outdated
Show resolved
Hide resolved
I'm OK with merging it if it's just a couple of utility methods. |
I'm fine with that. |
Signed-off-by: Leo Siepel <[email protected]>
The method nameshave been improved. Let me know if they need to be further adjusted or this can be merged. |
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
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.
Thanks, finally some StringUtils at our disposal again. 😄
The goal of this PR is to add some string utility methods to core. This way they are available to all the bindings and we can finally get rid of the remaining apache.common libs.
While doing so, it seemed many bindings make use of the same apache StringUtils methods. To prevent code duplication it might be better to get the most used ones merged into core.
For reference: openhab/openhab-addons#7722
I'll also create an issue and PR's to update the openhab-addons.
Closes: #3783