You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2018/05/25 09:19:53 UTC
[incubator-plc4x] branch master updated: Fixed some SonarQube
findings
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git
The following commit(s) were added to refs/heads/master by this push:
new c2a4ac4 Fixed some SonarQube findings
c2a4ac4 is described below
commit c2a4ac42f328620592add0e3fe18ae4d4a766e2c
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Fri May 25 11:19:48 2018 +0200
Fixed some SonarQube findings
---
.../java/org/apache/plc4x/camel/Plc4XConsumer.java | 7 ++++---
.../java/org/apache/plc4x/camel/Plc4XEndpoint.java | 20 ++++++++++++++++++++
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XConsumer.java b/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XConsumer.java
index 66335b9..0cb7a57 100644
--- a/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XConsumer.java
+++ b/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XConsumer.java
@@ -103,13 +103,14 @@ public class Plc4XConsumer extends ServiceSupport implements Consumer, java.util
}
}
- public Object unwrapIfSingle(List list) {
- if (list.size() < 1) {
+ private Object unwrapIfSingle(List list) {
+ if (list.isEmpty()) {
return null;
}
- if (list.size() < 2) {
+ if (list.size() == 1) {
return list.get(0);
}
return list;
}
+
}
diff --git a/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XEndpoint.java b/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XEndpoint.java
index 500c1cf..c740354 100644
--- a/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XEndpoint.java
+++ b/integrations/apache-camel/src/main/java/org/apache/plc4x/camel/Plc4XEndpoint.java
@@ -26,6 +26,8 @@ import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriPath;
import org.apache.plc4x.java.PlcDriverManager;
+import java.util.Objects;
+
@UriEndpoint(scheme = "plc4x", title = "PLC4X", syntax = "plc4x:driver", label = "plc4x")
public class Plc4XEndpoint extends DefaultEndpoint {
@@ -107,4 +109,22 @@ public class Plc4XEndpoint extends DefaultEndpoint {
public void setDataType(Class dataType) {
this.dataType = dataType;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof Plc4XEndpoint)) return false;
+ if (!super.equals(o)) return false;
+ Plc4XEndpoint that = (Plc4XEndpoint) o;
+ return Objects.equals(getDriver(), that.getDriver()) &&
+ Objects.equals(getAddress(), that.getAddress()) &&
+ Objects.equals(getDataType(), that.getDataType()) &&
+ Objects.equals(getPlcDriverManager(), that.getPlcDriverManager());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), getDriver(), getAddress(), getDataType(), getPlcDriverManager());
+ }
+
}
--
To stop receiving notification emails like this one, please contact
cdutz@apache.org.