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 2018/03/15 11:55:21 UTC

[incubator-plc4x] 03/04: simplified AMSTcpPacket

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

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

commit 9799a98d13decfe82e4f0b09a209365444c8a241
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Mar 15 12:05:29 2018 +0100

    simplified AMSTcpPacket
---
 .../java/org/apache/plc4x/java/ads/api/tcp/AmsTCPPacket.java  | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/tcp/AmsTCPPacket.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/tcp/AmsTCPPacket.java
index 243852e..43512cf 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/tcp/AmsTCPPacket.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/tcp/AmsTCPPacket.java
@@ -19,7 +19,6 @@
 package org.apache.plc4x.java.ads.api.tcp;
 
 import io.netty.buffer.ByteBuf;
-import org.apache.plc4x.java.ads.api.generic.AdsData;
 import org.apache.plc4x.java.ads.api.generic.AmsHeader;
 import org.apache.plc4x.java.ads.api.generic.AmsPacket;
 import org.apache.plc4x.java.ads.api.util.ByteReadable;
@@ -33,14 +32,14 @@ public class AmsTCPPacket implements ByteReadable {
 
     private AmsTCPPacket(AmsTcpHeader amsTcpHeader, AmsPacket amsPacket) {
         this.amsTcpHeader = requireNonNull(amsTcpHeader);
-        this.amsPacket = amsPacket;
+        this.amsPacket = requireNonNull(amsPacket);
     }
 
     private AmsTCPPacket(AmsPacket amsPacket) {
-        this.amsPacket = amsPacket;
+        this.amsPacket = requireNonNull(amsPacket);
         // It is important that we wrap the ads data call as this will initialized in the constructor
         // so this value will be null if we call adsData now.
-        this.amsTcpHeader = AmsTcpHeader.of(requireNonNull(amsPacket.getAmsHeader()), () -> getAdsData().getCalculatedLength());
+        this.amsTcpHeader = AmsTcpHeader.of(requireNonNull(amsPacket.getAmsHeader()), amsPacket);
     }
 
     public AmsTcpHeader getAmsTcpHeader() {
@@ -55,10 +54,6 @@ public class AmsTCPPacket implements ByteReadable {
         return amsPacket.getAmsHeader();
     }
 
-    public AdsData getAdsData() {
-        return amsPacket.getAdsData();
-    }
-
     @Override
     public ByteBuf getByteBuf() {
         return buildByteBuff(amsTcpHeader, amsPacket);

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