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 2022/03/08 14:10:14 UTC

[plc4x-build-tools] branch develop updated: fix(codegen): Added more testcases for the new field types and added support for them in Java, C and Go

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-build-tools.git


The following commit(s) were added to refs/heads/develop by this push:
     new 49f41ca  fix(codegen): Added more testcases for the new field types and added support for them in Java, C and Go
49f41ca is described below

commit 49f41ca4af64e634f5c408e703003639db9a8449
Author: cdutz <ch...@c-ware.de>
AuthorDate: Tue Mar 8 15:09:59 2022 +0100

    fix(codegen): Added more testcases for the new field types and added support for them in Java, C and Go
---
 .../types/definitions/ComplexTypeDefinition.java           | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/code-generation/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/definitions/ComplexTypeDefinition.java b/code-generation/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/definitions/ComplexTypeDefinition.java
index 6428fc6..dcb7314 100644
--- a/code-generation/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/definitions/ComplexTypeDefinition.java
+++ b/code-generation/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/definitions/ComplexTypeDefinition.java
@@ -201,6 +201,20 @@ public interface ComplexTypeDefinition extends TypeDefinition {
     }
 
     /**
+     * Returns a {@link NamedField} defined by {@code fieldName}.
+     *
+     * @param fieldName the fieldName to search for
+     * @return {@link NamedField} if found.
+     */
+    default Optional<NamedField> getNamedFieldByName(String fieldName) {
+        return this.getFields().stream()
+                .filter(FieldConversions::isNamedField)
+                .map(field -> (NamedField) field)
+                .filter(namedField -> namedField.getName().equals(fieldName))
+                .findFirst();
+    }
+
+    /**
      * Returns a {@link PropertyField} defined by {@code fieldName}.
      *
      * @param fieldName the fieldName to search for