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/02 12:11:03 UTC
[incubator-plc4x] branch master updated: increase performance by
eliminating loops for building.
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
The following commit(s) were added to refs/heads/master by this push:
new e07180c increase performance by eliminating loops for building.
e07180c is described below
commit e07180ce940ad4292d9a6e833b17330328044503
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Fri Mar 2 13:10:59 2018 +0100
increase performance by eliminating loops for building.
---
.../commands/ADSAddDeviceNotificationRequest.java | 10 ++++++-
.../commands/ADSAddDeviceNotificationResponse.java | 5 +++-
.../ADSDeleteDeviceNotificationRequest.java | 4 ++-
.../ADSDeleteDeviceNotificationResponse.java | 4 ++-
.../api/commands/ADSDeviceNotificationRequest.java | 9 ++++--
.../api/commands/ADSReadDeviceInfoResponse.java | 10 +++++--
.../java/ads/api/commands/ADSReadRequest.java | 8 +++--
.../java/ads/api/commands/ADSReadResponse.java | 8 +++--
.../ads/api/commands/ADSReadStateResponse.java | 4 ++-
.../java/ads/api/commands/ADSReadWriteRequest.java | 8 ++++-
.../ads/api/commands/ADSReadWriteResponse.java | 6 +++-
.../ads/api/commands/ADSWriteControlRequest.java | 7 ++++-
.../ads/api/commands/ADSWriteControlResponse.java | 4 ++-
.../java/ads/api/commands/ADSWriteRequest.java | 7 ++++-
.../java/ads/api/commands/ADSWriteResponse.java | 2 +-
.../api/commands/types/AdsNotificationSample.java | 8 +++--
.../ads/api/commands/types/AdsStampHeader.java | 10 +++++--
.../plc4x/java/ads/api/generic/AMSHeader.java | 22 +++++++-------
.../plc4x/java/ads/api/generic/AMSTCPHeader.java | 4 +--
.../plc4x/java/ads/api/generic/AMSTCPPacket.java | 8 ++---
.../plc4x/java/ads/api/util/ByteReadableUtils.java | 35 ----------------------
21 files changed, 107 insertions(+), 76 deletions(-)
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSAddDeviceNotificationRequest.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSAddDeviceNotificationRequest.java
index 7e96a3c..3a03b11 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSAddDeviceNotificationRequest.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSAddDeviceNotificationRequest.java
@@ -100,7 +100,15 @@ public class ADSAddDeviceNotificationRequest extends ADSAbstractRequest {
@Override
public ADSData getAdsData() {
- return buildADSData(indexGroup, indexOffset, length, transmissionMode, maxDelay, cycleTime, reserved);
+ return buildADSData(
+ indexGroup.getByteBuf(),
+ indexOffset.getByteBuf(),
+ length.getByteBuf(),
+ transmissionMode.getByteBuf(),
+ maxDelay.getByteBuf(),
+ cycleTime.getByteBuf(),
+ reserved.getByteBuf()
+ );
}
public static ADSAddDeviceNotificationRequest of(AMSTCPHeader amstcpHeader, AMSHeader amsHeader, IndexGroup indexGroup, IndexOffset indexOffset, Length length, TransmissionMode transmissionMode, MaxDelay maxDelay, CycleTime cycleTime) {
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSAddDeviceNotificationResponse.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSAddDeviceNotificationResponse.java
index db59dd6..c0b650e 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSAddDeviceNotificationResponse.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSAddDeviceNotificationResponse.java
@@ -76,7 +76,10 @@ public class ADSAddDeviceNotificationResponse extends ADSAbstractResponse {
@Override
public ADSData getAdsData() {
- return buildADSData(result, notificationHandle);
+ return buildADSData(
+ result.getByteBuf(),
+ notificationHandle.getByteBuf()
+ );
}
@Override
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSDeleteDeviceNotificationRequest.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSDeleteDeviceNotificationRequest.java
index 44f0258..a0b4b84 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSDeleteDeviceNotificationRequest.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSDeleteDeviceNotificationRequest.java
@@ -73,7 +73,9 @@ public class ADSDeleteDeviceNotificationRequest extends ADSAbstractRequest {
@Override
public ADSData getAdsData() {
- return buildADSData(notificationHandle);
+ return buildADSData(
+ notificationHandle.getByteBuf()
+ );
}
@Override
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSDeleteDeviceNotificationResponse.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSDeleteDeviceNotificationResponse.java
index 14de8ff..fe03098 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSDeleteDeviceNotificationResponse.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSDeleteDeviceNotificationResponse.java
@@ -64,7 +64,9 @@ public class ADSDeleteDeviceNotificationResponse extends ADSAbstractResponse {
@Override
public ADSData getAdsData() {
- return buildADSData(result);
+ return buildADSData(
+ result.getByteBuf()
+ );
}
@Override
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSDeviceNotificationRequest.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSDeviceNotificationRequest.java
index 24fa24b..e4e70a1 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSDeviceNotificationRequest.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSDeviceNotificationRequest.java
@@ -18,6 +18,7 @@
*/
package org.apache.plc4x.java.ads.api.commands;
+import io.netty.buffer.ByteBuf;
import org.apache.plc4x.java.ads.api.commands.types.AdsStampHeader;
import org.apache.plc4x.java.ads.api.commands.types.Length;
import org.apache.plc4x.java.ads.api.commands.types.Stamps;
@@ -33,6 +34,7 @@ import org.apache.plc4x.java.ads.api.util.LengthSupplier;
import java.util.List;
+import static io.netty.buffer.Unpooled.wrappedBuffer;
import static java.util.Objects.requireNonNull;
/**
@@ -118,7 +120,10 @@ public class ADSDeviceNotificationRequest extends ADSAbstractRequest {
@Override
public ADSData getAdsData() {
- return buildADSData(getLength(), stamps, buildADSData(adsStampHeaders.toArray(new ByteReadable[adsStampHeaders.size()])));
+ return buildADSData(
+ getLength().getByteBuf(),
+ stamps.getByteBuf(),
+ wrappedBuffer(adsStampHeaders.stream().map(ByteReadable::getByteBuf).toArray(ByteBuf[]::new)));
}
@Override
@@ -136,7 +141,7 @@ public class ADSDeviceNotificationRequest extends ADSAbstractRequest {
return false;
if (!stamps.equals(that.stamps))
return false;
-
+
return adsStampHeaders.equals(that.adsStampHeaders);
}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadDeviceInfoResponse.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadDeviceInfoResponse.java
index 3f11b28..baed360 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadDeviceInfoResponse.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadDeviceInfoResponse.java
@@ -104,7 +104,13 @@ public class ADSReadDeviceInfoResponse extends ADSAbstractResponse {
@Override
public ADSData getAdsData() {
- return buildADSData(result, majorVersion, minorVersion, version, device);
+ return buildADSData(
+ result.getByteBuf(),
+ majorVersion.getByteBuf(),
+ minorVersion.getByteBuf(),
+ version.getByteBuf(),
+ device.getByteBuf()
+ );
}
@Override
@@ -126,7 +132,7 @@ public class ADSReadDeviceInfoResponse extends ADSAbstractResponse {
return false;
if (!version.equals(that.version))
return false;
-
+
return device.equals(that.device);
}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadRequest.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadRequest.java
index 880f3f3..65ed495 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadRequest.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadRequest.java
@@ -99,7 +99,11 @@ public class ADSReadRequest extends ADSAbstractRequest {
@Override
public ADSData getAdsData() {
- return buildADSData(indexGroup, indexOffset, length);
+ return buildADSData(
+ indexGroup.getByteBuf(),
+ indexOffset.getByteBuf(),
+ length.getByteBuf()
+ );
}
@Override
@@ -117,7 +121,7 @@ public class ADSReadRequest extends ADSAbstractRequest {
return false;
if (!indexOffset.equals(that.indexOffset))
return false;
-
+
return length.equals(that.length);
}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadResponse.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadResponse.java
index 8a38d58..1386d6d 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadResponse.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadResponse.java
@@ -79,7 +79,11 @@ public class ADSReadResponse extends ADSAbstractResponse {
@Override
public ADSData getAdsData() {
- return buildADSData(result, getLength(), data);
+ return buildADSData(
+ result.getByteBuf(),
+ getLength().getByteBuf(),
+ data.getByteBuf()
+ );
}
public Result getResult() {
@@ -109,7 +113,7 @@ public class ADSReadResponse extends ADSAbstractResponse {
return false;
if (!getLength().equals(that.getLength()))
return false;
-
+
return data.equals(that.data);
}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadStateResponse.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadStateResponse.java
index 53e8985..ae88895 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadStateResponse.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadStateResponse.java
@@ -64,7 +64,9 @@ public class ADSReadStateResponse extends ADSAbstractResponse {
@Override
public ADSData getAdsData() {
- return buildADSData(result);
+ return buildADSData(
+ result.getByteBuf()
+ );
}
@Override
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadWriteRequest.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadWriteRequest.java
index ef82e33..7574d29 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadWriteRequest.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadWriteRequest.java
@@ -125,7 +125,13 @@ public class ADSReadWriteRequest extends ADSAbstractRequest {
@Override
public ADSData getAdsData() {
- return buildADSData(indexGroup, indexOffset, readLength, getWriteLength(), data);
+ return buildADSData(
+ indexGroup.getByteBuf(),
+ indexOffset.getByteBuf(),
+ readLength.getByteBuf(),
+ getWriteLength().getByteBuf(),
+ data.getByteBuf()
+ );
}
@Override
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadWriteResponse.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadWriteResponse.java
index 8328882..21fbb2e 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadWriteResponse.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSReadWriteResponse.java
@@ -93,7 +93,11 @@ public class ADSReadWriteResponse extends ADSAbstractResponse {
@Override
public ADSData getAdsData() {
- return buildADSData(result, getLength(), data);
+ return buildADSData(
+ result.getByteBuf(),
+ getLength().getByteBuf(),
+ data.getByteBuf()
+ );
}
@Override
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSWriteControlRequest.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSWriteControlRequest.java
index d2f7121..61a851f 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSWriteControlRequest.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSWriteControlRequest.java
@@ -117,7 +117,12 @@ public class ADSWriteControlRequest extends ADSAbstractRequest {
@Override
public ADSData getAdsData() {
- return buildADSData(adsState, deviceState, getLength(), data);
+ return buildADSData(
+ adsState.getByteBuf(),
+ deviceState.getByteBuf(),
+ getLength().getByteBuf(),
+ data.getByteBuf()
+ );
}
@Override
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSWriteControlResponse.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSWriteControlResponse.java
index 86e2b0a..c8bcd37 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSWriteControlResponse.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSWriteControlResponse.java
@@ -63,7 +63,9 @@ public class ADSWriteControlResponse extends ADSAbstractResponse {
@Override
public ADSData getAdsData() {
- return buildADSData(result);
+ return buildADSData(
+ result.getByteBuf()
+ );
}
@Override
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSWriteRequest.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSWriteRequest.java
index 6ce66a6..7d03778 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSWriteRequest.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSWriteRequest.java
@@ -115,7 +115,12 @@ public class ADSWriteRequest extends ADSAbstractRequest {
@Override
public ADSData getAdsData() {
- return buildADSData(indexGroup, indexOffset, getLength(), data);
+ return buildADSData(
+ indexGroup.getByteBuf(),
+ indexOffset.getByteBuf(),
+ getLength().getByteBuf(),
+ data.getByteBuf()
+ );
}
@Override
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSWriteResponse.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSWriteResponse.java
index fc3de95..859f5f8 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSWriteResponse.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/ADSWriteResponse.java
@@ -64,7 +64,7 @@ public class ADSWriteResponse extends ADSAbstractResponse {
@Override
public ADSData getAdsData() {
- return buildADSData(result);
+ return buildADSData(result.getByteBuf());
}
@Override
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/AdsNotificationSample.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/AdsNotificationSample.java
index 325b6e3..09d055a 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/AdsNotificationSample.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/AdsNotificationSample.java
@@ -22,8 +22,8 @@ import io.netty.buffer.ByteBuf;
import org.apache.plc4x.java.ads.api.util.ByteReadable;
import org.apache.plc4x.java.ads.api.util.LengthSupplier;
+import static io.netty.buffer.Unpooled.wrappedBuffer;
import static java.util.Objects.requireNonNull;
-import static org.apache.plc4x.java.ads.api.util.ByteReadableUtils.buildByteBuff;
public class AdsNotificationSample implements ByteReadable {
@@ -66,7 +66,11 @@ public class AdsNotificationSample implements ByteReadable {
@Override
public ByteBuf getByteBuf() {
- return buildByteBuff(notificationHandle, getSampleSize(), data);
+ return wrappedBuffer(
+ notificationHandle.getByteBuf(),
+ getSampleSize().getByteBuf(),
+ data.getByteBuf()
+ );
}
public NotificationHandle getNotificationHandle() {
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/AdsStampHeader.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/AdsStampHeader.java
index 2c9b56b..4dea0e4 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/AdsStampHeader.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/AdsStampHeader.java
@@ -23,8 +23,8 @@ import org.apache.plc4x.java.ads.api.util.ByteReadable;
import java.util.List;
+import static io.netty.buffer.Unpooled.wrappedBuffer;
import static java.util.Objects.requireNonNull;
-import static org.apache.plc4x.java.ads.api.util.ByteReadableUtils.buildByteBuff;
public class AdsStampHeader implements ByteReadable {
@@ -63,7 +63,11 @@ public class AdsStampHeader implements ByteReadable {
@Override
public ByteBuf getByteBuf() {
- return buildByteBuff(timeStamp, samples, () -> buildByteBuff(adsNotificationSamples.toArray(new ByteReadable[adsNotificationSamples.size()])));
+ return wrappedBuffer(
+ timeStamp.getByteBuf(),
+ samples.getByteBuf(),
+ wrappedBuffer(adsNotificationSamples.stream().map(ByteReadable::getByteBuf).toArray(ByteBuf[]::new))
+ );
}
public TimeStamp getTimeStamp() {
@@ -91,7 +95,7 @@ public class AdsStampHeader implements ByteReadable {
return false;
if (!samples.equals(that.samples))
return false;
-
+
return adsNotificationSamples.equals(that.adsNotificationSamples);
}
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/AMSHeader.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/AMSHeader.java
index 72bb6f0..3a64b38 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/AMSHeader.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/AMSHeader.java
@@ -19,12 +19,12 @@
package org.apache.plc4x.java.ads.api.generic;
import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.apache.plc4x.java.ads.api.generic.types.*;
import org.apache.plc4x.java.ads.api.util.ByteReadable;
import org.apache.plc4x.java.ads.api.util.LengthSupplier;
import static java.util.Objects.requireNonNull;
-import static org.apache.plc4x.java.ads.api.util.ByteReadableUtils.buildByteBuff;
/**
* AMS Header 32 bytes The AMS/TCP-Header contains the addresses of the transmitter and receiver. In addition the AMS error code , the ADS command Id and some other information.
@@ -108,16 +108,16 @@ public class AMSHeader implements ByteReadable {
@Override
public ByteBuf getByteBuf() {
- return buildByteBuff(
- targetAmsNetId,
- targetAmsPort,
- sourceAmsNetId,
- sourceAmsPort,
- commandId,
- stateFlags,
- getDataLength(),
- code,
- invokeId);
+ return Unpooled.wrappedBuffer(
+ targetAmsNetId.getByteBuf(),
+ targetAmsPort.getByteBuf(),
+ sourceAmsNetId.getByteBuf(),
+ sourceAmsPort.getByteBuf(),
+ commandId.getByteBuf(),
+ stateFlags.getByteBuf(),
+ getDataLength().getByteBuf(),
+ code.getByteBuf(),
+ invokeId.getByteBuf());
}
public AMSNetId getTargetAmsNetId() {
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/AMSTCPHeader.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/AMSTCPHeader.java
index d7d7e0a..3ff396c 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/AMSTCPHeader.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/AMSTCPHeader.java
@@ -19,13 +19,13 @@
package org.apache.plc4x.java.ads.api.generic;
import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.apache.plc4x.java.ads.api.generic.types.TcpLength;
import org.apache.plc4x.java.ads.api.util.ByteReadable;
import org.apache.plc4x.java.ads.api.util.ByteValue;
import org.apache.plc4x.java.ads.api.util.LengthSupplier;
import static java.util.Objects.requireNonNull;
-import static org.apache.plc4x.java.ads.api.util.ByteReadableUtils.buildByteBuff;
/**
* AMS/TCP Header 6 bytes contains the tcpLength of the data packet.
@@ -69,7 +69,7 @@ public class AMSTCPHeader implements ByteReadable {
@Override
public ByteBuf getByteBuf() {
- return buildByteBuff(reserved, getTcpLength());
+ return Unpooled.wrappedBuffer(reserved.getByteBuf(), getTcpLength().getByteBuf());
}
/**
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/AMSTCPPacket.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/AMSTCPPacket.java
index cb1bafd..e9ab7a7 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/AMSTCPPacket.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/generic/AMSTCPPacket.java
@@ -19,12 +19,12 @@
package org.apache.plc4x.java.ads.api.generic;
import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.apache.plc4x.java.ads.api.commands.ADSCommandType;
import org.apache.plc4x.java.ads.api.generic.types.*;
import org.apache.plc4x.java.ads.api.util.ByteReadable;
import static java.util.Objects.requireNonNull;
-import static org.apache.plc4x.java.ads.api.util.ByteReadableUtils.buildByteBuff;
public abstract class AMSTCPPacket implements ByteReadable {
private final AMSTCPHeader amsTcpHeader;
@@ -72,11 +72,11 @@ public abstract class AMSTCPPacket implements ByteReadable {
@Override
public ByteBuf getByteBuf() {
- return buildByteBuff(amsTcpHeader, amsHeader, getAdsData());
+ return Unpooled.wrappedBuffer(amsTcpHeader.getByteBuf(), amsHeader.getByteBuf(), getAdsData().getByteBuf());
}
- protected ADSData buildADSData(ByteReadable... byteReadables) {
- return () -> buildByteBuff(byteReadables);
+ protected ADSData buildADSData(ByteBuf... byteReadables) {
+ return () -> Unpooled.wrappedBuffer(byteReadables);
}
@Override
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/ByteReadableUtils.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/ByteReadableUtils.java
deleted file mode 100644
index fc9898b..0000000
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/ByteReadableUtils.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-package org.apache.plc4x.java.ads.api.util;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-
-import java.util.Arrays;
-
-public class ByteReadableUtils {
-
- private ByteReadableUtils() {
- // Singleton
- }
-
- public static ByteBuf buildByteBuff(ByteReadable... byteReadables) {
- return Unpooled.wrappedBuffer(Arrays.stream(byteReadables).map(ByteReadable::getByteBuf).toArray(ByteBuf[]::new));
- }
-}
--
To stop receiving notification emails like this one, please contact
sruehl@apache.org.