Skip to content
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

[homematic] Remove dependency org.apache.commons.* from CcuGateway #10028

Closed
wants to merge 1 commit into from

Conversation

pavog
Copy link
Contributor

@pavog pavog commented Feb 2, 2021

This removes the dependencies org.apache.commons.lang.StringUtils and org.apache.commons.lang.ObjectUtils from CcuGateway

This replaces the functions from StringUtils and ObjectUtils with standard Java functions.
In most cases the functions from StringUtils just cover standard Java functions with null or empty-string checks.

Related to #7722

@pavog pavog requested a review from gerrieg as a code owner February 2, 2021 12:03
Remove dependencies org.apache.commons.lang.StringUtils and org.apache.commons.lang.ObjectUtils from CcuGateway

Signed-off-by: Paul Vogel <[email protected]>
script = StringUtils.trim(script);
if (StringUtils.isEmpty(script)) {
script = script == null ? null : script.trim();
if (script == null || script.length() == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (script == null || script.length() == 0) {
if (script == null || script.isEmpty()) {

@@ -210,7 +213,14 @@ protected void executeScript(HmDatapoint dp) throws IOException {
.header(HttpHeader.CONTENT_TYPE, "text/plain;charset=" + config.getEncoding()).send();

String result = new String(response.getContent(), config.getEncoding());
result = StringUtils.substringBeforeLast(result, "<xml><exec>");
if (result.length() != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (result.length() != 0) {
if (!result.isEmpty()) {

result.put(script.name, StringUtils.trimToNull(script.data));
// trim data to null (if it's empty)
String data = script.data == null ? null : script.data.trim();
data = (data == null || data.length() == 0) ? null : data;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
data = (data == null || data.length() == 0) ? null : data;
data = (data == null || data.isEmpty()) ? null : data;

@pavog
Copy link
Contributor Author

pavog commented Feb 4, 2021

@MHerbst opened pr #10035 which removes all usages of apache commons functions in the homematic binding. So this pr is no longer needed. Thank you guys!

@pavog pavog closed this Feb 4, 2021
@pavog pavog deleted the patch-3 branch February 4, 2021 10:44
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