You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2022/06/27 14:17:16 UTC

[plc4x] 02/02: refactor(plc4j/spi): minor cleanup

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

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 5aca70984adfbcb5faedb1dc3e6b3af2d1b8748f
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Mon Jun 27 16:17:01 2022 +0200

    refactor(plc4j/spi): minor cleanup
---
 .../org/apache/plc4x/java/spi/generation/StaticHelper.java   | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/StaticHelper.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/StaticHelper.java
index 51d7e3702..60e0fccd3 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/StaticHelper.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/StaticHelper.java
@@ -28,15 +28,14 @@ public class StaticHelper {
 
     public static int ARRAY_SIZE_IN_BYTES(Object obj) {
         if (obj instanceof List) {
-            List list = (List) obj;
+            List<?> list = (List<?>) obj;
             int numBytes = 0;
             for (Object element : list) {
-                if (element instanceof Message) {
-                    numBytes += ((Message) element).getLengthInBytes();
-                } else {
+                if (!(element instanceof Message)) {
                     throw new RuntimeException(
                         "Array elements for array size in bytes must implement Message interface");
                 }
+                numBytes += ((Message) element).getLengthInBytes();
             }
             return numBytes;
         }
@@ -44,12 +43,11 @@ public class StaticHelper {
             Object[] arr = (Object[]) obj;
             int numBytes = 0;
             for (Object element : arr) {
-                if (element instanceof Message) {
-                    numBytes += ((Message) element).getLengthInBytes();
-                } else {
+                if (!(element instanceof Message)) {
                     throw new RuntimeException(
                         "Array elements for array size in bytes must implement Message interface");
                 }
+                numBytes += ((Message) element).getLengthInBytes();
             }
             return numBytes;
         }