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/07/30 14:32:47 UTC

[plc4x] branch develop updated: - Added serializer arguments

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


The following commit(s) were added to refs/heads/develop by this push:
     new 4cc954c  - Added serializer arguments
4cc954c is described below

commit 4cc954c4d2f8ff8f71ef1b59699c9008621f1743
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Tue Jul 30 16:32:40 2019 +0200

    - Added serializer arguments
---
 .../src/main/resources/templates/java/io-template.ftlh             | 7 ++++++-
 .../src/main/java/org/apache/plc4x/java/utils/MessageIO.java       | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/build-utils/language-java/src/main/resources/templates/java/io-template.ftlh b/build-utils/language-java/src/main/resources/templates/java/io-template.ftlh
index 32ef907..ff72cd1 100644
--- a/build-utils/language-java/src/main/resources/templates/java/io-template.ftlh
+++ b/build-utils/language-java/src/main/resources/templates/java/io-template.ftlh
@@ -173,7 +173,12 @@ public class ${typeName}IO implements MessageIO<${typeName}<#if helper.isDiscrim
         </#if>
     }
 
-    public void serialize(WriteBuffer io, ${typeName} value) throws ParseException {
+    public void serialize(WriteBuffer io, ${typeName} value, Object... args) throws ParseException {
+<#if type.parserArguments?has_content>
+<#list type.parserArguments as parserArgument>
+        ${helper.getLanguageTypeNameForSpecType(parserArgument.type)} ${parserArgument.name} = (${helper.getLanguageTypeNameForSpecType(parserArgument.type)}) args[${parserArgument?index}];
+</#list>
+</#if>
 <#list type.fields as field>
 <#switch field.typeName>
     <#case "array">
diff --git a/plc4j/utils/driver-base-java/src/main/java/org/apache/plc4x/java/utils/MessageIO.java b/plc4j/utils/driver-base-java/src/main/java/org/apache/plc4x/java/utils/MessageIO.java
index 03eb18d..1375d1a 100644
--- a/plc4j/utils/driver-base-java/src/main/java/org/apache/plc4x/java/utils/MessageIO.java
+++ b/plc4j/utils/driver-base-java/src/main/java/org/apache/plc4x/java/utils/MessageIO.java
@@ -23,6 +23,6 @@ public interface MessageIO<PARSER_TYPE, SERIALIZER_TYPE> {
 
     PARSER_TYPE parse(ReadBuffer io, Object... args) throws ParseException;
 
-    void serialize(WriteBuffer io, SERIALIZER_TYPE value) throws ParseException;
+    void serialize(WriteBuffer io, SERIALIZER_TYPE value, Object... args) throws ParseException;
 
 }