This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new d9357de3639 (chores) camel-plc4x: fixed formatting issues
d9357de3639 is described below
commit d9357de36392bd99309e83f231e00cd487ba836d
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Fri Nov 4 13:19:13 2022 +0100
(chores) camel-plc4x: fixed formatting issues
---
.../camel/component/plc4x/Plc4XEndpoint.java | 26 +++---
.../org/apache/camel/component/plc4x/TagData.java | 104 ++++++++++-----------
.../src/test/resources/log4j2.properties | 33 +++----
3 files changed, 82 insertions(+), 81 deletions(-)
diff --git
a/components/camel-plc4x/src/main/java/org/apache/camel/component/plc4x/Plc4XEndpoint.java
b/components/camel-plc4x/src/main/java/org/apache/camel/component/plc4x/Plc4XEndpoint.java
index 2b45e0cdff5..2fcb95d44a9 100644
---
a/components/camel-plc4x/src/main/java/org/apache/camel/component/plc4x/Plc4XEndpoint.java
+++
b/components/camel-plc4x/src/main/java/org/apache/camel/component/plc4x/Plc4XEndpoint.java
@@ -53,6 +53,19 @@ public class Plc4XEndpoint extends DefaultEndpoint {
@Metadata(label = "consumer", description = "Interval on which the Trigger
should be checked")
private int period;
+ private PlcDriverManager plcDriverManager;
+ private PlcConnection connection;
+ private String uri;
+
+ public Plc4XEndpoint(String endpointUri, Component component) throws
PlcConnectionException {
+ super(endpointUri, component);
+ this.plcDriverManager = new PlcDriverManager();
+ //Here we establish the connection in the endpoint, as it is created
once during the context
+ // to avoid disconnecting and reconnecting for every request
+ this.uri = endpointUri.replaceFirst("plc4x:/?/?", "");
+ this.connection = plcDriverManager.getConnection(this.uri);
+ }
+
public int getPeriod() {
return period;
}
@@ -61,10 +74,6 @@ public class Plc4XEndpoint extends DefaultEndpoint {
this.period = period;
}
- private PlcDriverManager plcDriverManager;
- private PlcConnection connection;
- private String uri;
-
public String getUri() {
return uri;
}
@@ -86,15 +95,6 @@ public class Plc4XEndpoint extends DefaultEndpoint {
}
}
- public Plc4XEndpoint(String endpointUri, Component component) throws
PlcConnectionException {
- super(endpointUri, component);
- this.plcDriverManager = new PlcDriverManager();
- //Here we establish the connection in the endpoint, as it is created
once during the context
- // to avoid disconnecting and reconnecting for every request
- this.uri = endpointUri.replaceFirst("plc4x:/?/?", "");
- this.connection = plcDriverManager.getConnection(this.uri);
- }
-
public PlcConnection getConnection() {
return connection;
}
diff --git
a/components/camel-plc4x/src/main/java/org/apache/camel/component/plc4x/TagData.java
b/components/camel-plc4x/src/main/java/org/apache/camel/component/plc4x/TagData.java
index 14de2a73355..a191d1c3406 100644
---
a/components/camel-plc4x/src/main/java/org/apache/camel/component/plc4x/TagData.java
+++
b/components/camel-plc4x/src/main/java/org/apache/camel/component/plc4x/TagData.java
@@ -29,6 +29,58 @@ public class TagData {
private String query;
private Object value;
+ private Map<Class<?>, Predicate<String>> canParse = new HashMap<>();
+ {
+ canParse.put(Integer.TYPE, s -> {
+ try {
+ Integer.parseInt(s);
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ });
+ canParse.put(Long.TYPE, s -> {
+ try {
+ Long.parseLong(s);
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ });
+ canParse.put(Short.TYPE, s -> {
+ try {
+ Short.parseShort(s);
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ });
+ canParse.put(Boolean.TYPE, s -> {
+ try {
+ Boolean.parseBoolean(s);
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ });
+ canParse.put(Double.TYPE, s -> {
+ try {
+ Double.parseDouble(s);
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ });
+ canParse.put(Float.TYPE, s -> {
+ try {
+ Float.parseFloat(s);
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ });
+ };
+
public TagData(String alias, String query, Object value) {
this.tagName = alias;
this.query = query;
@@ -86,58 +138,6 @@ public class TagData {
}
}
- private Map<Class<?>, Predicate<String>> canParse = new HashMap<>();
- {
- canParse.put(Integer.TYPE, s -> {
- try {
- Integer.parseInt(s);
- return true;
- } catch (Exception e) {
- return false;
- }
- });
- canParse.put(Long.TYPE, s -> {
- try {
- Long.parseLong(s);
- return true;
- } catch (Exception e) {
- return false;
- }
- });
- canParse.put(Short.TYPE, s -> {
- try {
- Short.parseShort(s);
- return true;
- } catch (Exception e) {
- return false;
- }
- });
- canParse.put(Boolean.TYPE, s -> {
- try {
- Boolean.parseBoolean(s);
- return true;
- } catch (Exception e) {
- return false;
- }
- });
- canParse.put(Double.TYPE, s -> {
- try {
- Double.parseDouble(s);
- return true;
- } catch (Exception e) {
- return false;
- }
- });
- canParse.put(Float.TYPE, s -> {
- try {
- Float.parseFloat(s);
- return true;
- } catch (Exception e) {
- return false;
- }
- });
- };
-
@Override
public String toString() {
return "(" + tagName + ") : " + value;
diff --git a/components/camel-plc4x/src/test/resources/log4j2.properties
b/components/camel-plc4x/src/test/resources/log4j2.properties
index a409c5d4e7e..39ed00c0013 100644
--- a/components/camel-plc4x/src/test/resources/log4j2.properties
+++ b/components/camel-plc4x/src/test/resources/log4j2.properties
@@ -1,19 +1,20 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
appender.file.type = File
appender.file.name = file
appender.file.fileName = target/camel-plc4x-test.log