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 2019/10/10 09:22:25 UTC

[plc4x] 01/03: - Made the java pojo template safe for null arrays - Added enum fileds to the getLengthInBytes method

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

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

commit 6e048afe51fdace30935c5c20f1c21639889e0b6
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Thu Oct 10 11:20:19 2019 +0200

    - Made the java pojo template safe for null arrays
    - Added enum fileds to the getLengthInBytes method
---
 .../src/main/resources/templates/java/pojo-template.ftlh      | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/build-utils/language-java/src/main/resources/templates/java/pojo-template.ftlh b/build-utils/language-java/src/main/resources/templates/java/pojo-template.ftlh
index 45b4545..a5c1e60 100644
--- a/build-utils/language-java/src/main/resources/templates/java/pojo-template.ftlh
+++ b/build-utils/language-java/src/main/resources/templates/java/pojo-template.ftlh
@@ -118,8 +118,10 @@ public<#if type.abstract> abstract</#if> class ${typeName}<#if type.parentType??
         <#if helper.isSimpleType(field.type)>
         lengthInBits += ${field.type.size} * ${field.name}.length;
         <#else>
-        for(Message element : ${field.name}) {
-            lengthInBits += element.getLengthInBytes() * 8;
+        if(${field.name} != null) {
+            for(Message element : ${field.name}) {
+                lengthInBits += element.getLengthInBytes() * 8;
+            }
         }
         </#if>
         <#break>
@@ -138,6 +140,11 @@ public<#if type.abstract> abstract</#if> class ${typeName}<#if type.parentType??
         // Discriminator Field (${field.name})
         lengthInBits += ${field.type.size};
         <#break>
+    <#case "enum">
+
+        // Enum Field (${field.name})
+        lengthInBits += ${helper.getEnumBaseType(field.type).size};
+        <#break>
     <#case "implicit">
 
         // Implicit Field (${field.name})