This is an automated email from the ASF dual-hosted git repository.

dlaboss 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 b503eeb  cleanup sonar edgent complaints
     new ba8fad4  Merge pull request #6
b503eeb is described below

commit b503eebf7a2e1f9efd07bb60dd93bfe4f005bd7f
Author: Dale LaBossiere <dlab...@us.ibm.com>
AuthorDate: Mon Feb 26 13:49:20 2018 -0500

    cleanup sonar edgent complaints
---
 .../apache/plc4x/edgent/PlcConnectionAdapter.java  | 50 +++++++++++++---------
 1 file changed, 30 insertions(+), 20 deletions(-)

diff --git 
a/integrations/apache-edgent/src/main/java/org/apache/plc4x/edgent/PlcConnectionAdapter.java
 
b/integrations/apache-edgent/src/main/java/org/apache/plc4x/edgent/PlcConnectionAdapter.java
index eedfc79..bc4eaef 100644
--- 
a/integrations/apache-edgent/src/main/java/org/apache/plc4x/edgent/PlcConnectionAdapter.java
+++ 
b/integrations/apache-edgent/src/main/java/org/apache/plc4x/edgent/PlcConnectionAdapter.java
@@ -108,28 +108,38 @@ public class PlcConnectionAdapter implements 
AutoCloseable {
 
     <T> Supplier<T> newSupplier(Class<T> datatype, String addressStr) {
         PlcConnectionAdapter.checkDatatype(datatype);
-        return new Supplier<T>() {
-            private static final long serialVersionUID = 1L;
+        // satisfy sonar's "Reduce number of anonymous class lines" code smell
+        return new MySupplier<T>(datatype, addressStr);
+    }
+    
+    private class MySupplier<T> implements Supplier<T> {
+        private static final long serialVersionUID = 1L;
+        private Class<T> datatype;
+        private String addressStr;
+      
+        MySupplier(Class<T> datatype, String addressStr) {
+            this.datatype = datatype;
+            this.addressStr = addressStr;
+        }
 
-            @Override
-            public T get() {
-                PlcConnection connection = null;
-                Address address = null;
-                try {
-                    connection = getConnection();
-                    address = connection.parseAddress(addressStr);
-                    PlcReader reader = connection.getReader()
-                        .orElseThrow(() -> new NullPointerException("No reader 
available"));
-                    TypeSafePlcReadRequest<T> readRequest = 
PlcConnectionAdapter.newPlcReadRequest(datatype, address);
-                    return reader.read(readRequest).get().getResponseItem()
-                        .orElseThrow(() -> new IllegalStateException("No 
response available"))
-                        .getValues().get(0);
-                } catch (Exception e) {
-                    logger.error("reading from plc device {} {} failed", 
connection, address, e);
-                    return null;
-                }
+        @Override
+        public T get() {
+            PlcConnection connection = null;
+            Address address = null;
+            try {
+                connection = getConnection();
+                address = connection.parseAddress(addressStr);
+                PlcReader reader = connection.getReader()
+                  .orElseThrow(() -> new NullPointerException("No reader 
available"));
+                TypeSafePlcReadRequest<T> readRequest = 
PlcConnectionAdapter.newPlcReadRequest(datatype, address);
+                return reader.read(readRequest).get().getResponseItem()
+                  .orElseThrow(() -> new IllegalStateException("No response 
available"))
+                  .getValues().get(0);
+            } catch (Exception e) {
+                logger.error("reading from plc device {} {} failed", 
connection, address, e);
+                return null;
             }
-        };
+        }
     }
 
     Supplier<PlcReadResponse> newSupplier(PlcReadRequest readRequest) {

-- 
To stop receiving notification emails like this one, please contact
dlab...@apache.org.

Reply via email to