From bcb51d17aae76e5995b527cdc99ce4caef534c3b Mon Sep 17 00:00:00 2001 From: bmalinowsky Date: Sat, 24 Feb 2024 14:56:08 +0100 Subject: [PATCH] Minor formatting --- src/io/calimero/knxnetip/util/DIB.java | 14 +++----------- src/io/calimero/link/medium/TP1Ack.java | 19 ++++++++----------- .../calimero/knxnetip/KNXnetIPRouterTest.java | 10 +++++----- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/io/calimero/knxnetip/util/DIB.java b/src/io/calimero/knxnetip/util/DIB.java index 4d7e3752..c38b63f8 100644 --- a/src/io/calimero/knxnetip/util/DIB.java +++ b/src/io/calimero/knxnetip/util/DIB.java @@ -1,6 +1,6 @@ /* Calimero 2 - A library for KNX network access - Copyright (c) 2006, 2022 B. Malinowsky + Copyright (c) 2006, 2024 B. Malinowsky This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -95,7 +95,6 @@ public abstract class DIB /** * Creates a new DIB out of a byte array. - *

* * @param data byte array containing DIB structure * @param offset start offset of DIB in {@code data} @@ -113,7 +112,6 @@ protected DIB(final byte[] data, final int offset) throws KNXFormatException /** * Creates a new DIB and initializes basic fields. - *

* * @param dibSize total size of DIB in bytes, {@code dibSize > 0} * @param descriptionType one of the description type code constants of this class @@ -138,10 +136,7 @@ public final int getDescTypeCode() } /** - * Returns the structure length of this DIB in bytes. - *

- * - * @return structure length as unsigned byte + * {@return the structure length of this DIB in bytes as unsigned byte} */ public final int getStructLength() { @@ -149,10 +144,7 @@ public final int getStructLength() } /** - * Returns the byte representation of the whole DIB structure. - *

- * - * @return byte array containing structure + * {@return the byte representation of the whole DIB structure as byte array} */ public byte[] toByteArray() { diff --git a/src/io/calimero/link/medium/TP1Ack.java b/src/io/calimero/link/medium/TP1Ack.java index d92708c7..b2f5bedb 100644 --- a/src/io/calimero/link/medium/TP1Ack.java +++ b/src/io/calimero/link/medium/TP1Ack.java @@ -1,6 +1,6 @@ /* Calimero 2 - A library for KNX network access - Copyright (c) 2006, 2022 B. Malinowsky + Copyright (c) 2006, 2024 B. Malinowsky This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -75,16 +75,13 @@ public TP1Ack(final byte[] data, final int offset) throws KNXFormatException final int ctrl = data[offset] & 0xff; if ((ctrl & 0x33) != 0x00) throw new KNXFormatException("no TP1 ACK frame, invalid control field", ctrl); - if (ctrl == ACK) - ack = ACK; - else if (ctrl == NAK) - ack = NAK; - else if (ctrl == BUSY) - ack = BUSY; - else if (ctrl == NAK_BUSY) - ack = NAK_BUSY; - else - throw new KNXFormatException("no valid acknowledge type", ctrl); + ack = switch (ctrl) { + case ACK -> ACK; + case NAK -> NAK; + case BUSY -> BUSY; + case NAK_BUSY -> NAK_BUSY; + default -> throw new KNXFormatException("invalid acknowledge type", ctrl); + }; } @Override diff --git a/test/io/calimero/knxnetip/KNXnetIPRouterTest.java b/test/io/calimero/knxnetip/KNXnetIPRouterTest.java index 1111d7eb..eb1e8ad0 100644 --- a/test/io/calimero/knxnetip/KNXnetIPRouterTest.java +++ b/test/io/calimero/knxnetip/KNXnetIPRouterTest.java @@ -1,6 +1,6 @@ /* Calimero 2 - A library for KNX network access - Copyright (c) 2006, 2023 B. Malinowsky + Copyright (c) 2006, 2024 B. Malinowsky This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -36,6 +36,7 @@ package io.calimero.knxnetip; +import static io.calimero.knxnetip.KNXnetIPConnection.BlockingMode.NonBlocking; import static java.nio.ByteBuffer.allocate; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; @@ -43,7 +44,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; -import static io.calimero.knxnetip.KNXnetIPConnection.BlockingMode.NonBlocking; import java.io.IOException; import java.net.DatagramPacket; @@ -65,9 +65,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import tag.KnxnetIP; -import tag.KnxnetIPSequential; -import tag.Slow; import io.calimero.CloseEvent; import io.calimero.DataUnitBuilder; import io.calimero.FrameEvent; @@ -87,6 +84,9 @@ import io.calimero.knxnetip.servicetype.RoutingBusy; import io.calimero.knxnetip.servicetype.RoutingSystemBroadcast; import io.calimero.mgmt.PropertyAccess.PID; +import tag.KnxnetIP; +import tag.KnxnetIPSequential; +import tag.Slow; @KnxnetIP