Skip to content

Commit 08fa491

Browse files
committed
Unified util classes
1 parent 9fddde8 commit 08fa491

22 files changed

+57
-47
lines changed

src/main/java/com/hivemq/client/internal/logging/InternalLoggerFactory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/**
2323
* @author Silvio Giebl
2424
*/
25-
public class InternalLoggerFactory {
25+
public final class InternalLoggerFactory {
2626

2727
private static final boolean SLF4J_AVAILABLE;
2828

@@ -44,4 +44,6 @@ private static boolean isAvailable(final @NotNull String className) {
4444
}
4545
return new InternalNoopLogger(clazz);
4646
}
47+
48+
private InternalLoggerFactory() {}
4749
}

src/main/java/com/hivemq/client/internal/mqtt/codec/decoder/MqttMessageDecoderUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
*
3030
* @author Silvio Giebl
3131
*/
32-
public class MqttMessageDecoderUtil {
33-
34-
private MqttMessageDecoderUtil() {}
32+
public final class MqttMessageDecoderUtil {
3533

3634
public static void checkFixedHeaderFlags(final int expected, final int actual) throws MqttDecoderException {
3735
if (expected != actual) {
@@ -79,4 +77,6 @@ public static int decodePublishPacketIdentifier(final @NotNull MqttQos qos, fina
7977
}
8078
return in.readUnsignedShort();
8179
}
80+
81+
private MqttMessageDecoderUtil() {}
8282
}

src/main/java/com/hivemq/client/internal/mqtt/codec/decoder/mqtt3/Mqtt3MessageDecoderUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
*
2626
* @author Silvio Giebl
2727
*/
28-
class Mqtt3MessageDecoderUtil {
29-
30-
private Mqtt3MessageDecoderUtil() {}
28+
final class Mqtt3MessageDecoderUtil {
3129

3230
static @NotNull MqttDecoderException wrongReturnCode() {
3331
return new MqttDecoderException("wrong return code");
3432
}
33+
34+
private Mqtt3MessageDecoderUtil() {}
3535
}

src/main/java/com/hivemq/client/internal/mqtt/codec/decoder/mqtt5/Mqtt5MessageDecoderUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@
4040
*
4141
* @author Silvio Giebl
4242
*/
43-
class Mqtt5MessageDecoderUtil {
44-
45-
private Mqtt5MessageDecoderUtil() {}
43+
final class Mqtt5MessageDecoderUtil {
4644

4745
static @NotNull MqttDecoderException wrongReasonCode() {
4846
return new MqttDecoderException("wrong reason code");
@@ -264,4 +262,6 @@ private static void checkProblemInformationRequested(
264262
static long decodeSessionExpiryInterval(final long current, final @NotNull ByteBuf in) throws MqttDecoderException {
265263
return unsignedIntOnlyOnce(current, SESSION_EXPIRY_INTERVAL_FROM_CONNECT, "session expiry interval", in);
266264
}
265+
266+
private Mqtt5MessageDecoderUtil() {}
267267
}

src/main/java/com/hivemq/client/internal/mqtt/codec/encoder/MqttMessageEncoderUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333
*
3434
* @author Silvio Giebl
3535
*/
36-
public class MqttMessageEncoderUtil {
37-
38-
private MqttMessageEncoderUtil() {}
36+
public final class MqttMessageEncoderUtil {
3937

4038
/**
4139
* Calculates the encoded length of a MQTT message with the given remaining length.
@@ -96,4 +94,6 @@ public static void encodeOrEmpty(final @Nullable ByteBuffer byteBuffer, final @N
9694
message.getType() + " exceeded maximum packet size, minimal possible encoded length: " + encodedLength +
9795
", maximum: " + maxPacketSize + ".");
9896
}
97+
98+
private MqttMessageEncoderUtil() {}
9999
}

src/main/java/com/hivemq/client/internal/mqtt/codec/encoder/mqtt5/Mqtt5MessageEncoderUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232
*
3333
* @author Silvio Giebl
3434
*/
35-
class Mqtt5MessageEncoderUtil {
36-
37-
private Mqtt5MessageEncoderUtil() {}
35+
final class Mqtt5MessageEncoderUtil {
3836

3937
static int propertyEncodedLength(final @NotNull MqttUtf8StringImpl string) {
4038
return 1 + string.encodedLength();
@@ -147,4 +145,6 @@ static void encodeVariableByteIntegerProperty(
147145
encodeVariableByteIntegerProperty(propertyIdentifier, value, out);
148146
}
149147
}
148+
149+
private Mqtt5MessageEncoderUtil() {}
150150
}

src/main/java/com/hivemq/client/internal/mqtt/datatypes/MqttBinaryData.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@
2929
*
3030
* @author Silvio Giebl
3131
*/
32-
public class MqttBinaryData {
32+
public final class MqttBinaryData {
3333

3434
public static final int MAX_LENGTH = 65_535;
3535
public static final int EMPTY_LENGTH = 2;
3636

37-
private MqttBinaryData() {}
38-
3937
/**
4038
* Decodes binary data from the given byte buffer at the current reader index.
4139
*
@@ -154,4 +152,6 @@ public static int encodedLength(final @NotNull byte[] binary) {
154152
public static int encodedLength(final @NotNull ByteBuffer byteBuffer) {
155153
return 2 + byteBuffer.remaining();
156154
}
155+
156+
private MqttBinaryData() {}
157157
}

src/main/java/com/hivemq/client/internal/mqtt/datatypes/MqttVariableByteInteger.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*
2626
* @author Silvio Giebl
2727
*/
28-
public class MqttVariableByteInteger {
28+
public final class MqttVariableByteInteger {
2929

3030
public static final int NOT_ENOUGH_BYTES = -1;
3131
public static final int TOO_LARGE = -2;
@@ -40,8 +40,6 @@ public class MqttVariableByteInteger {
4040
public static final int FOUR_BYTES_MAX_VALUE = (1 << (VALUE_BITS * 4)) - 1;
4141
public static final int MAXIMUM_PACKET_SIZE_LIMIT = 1 + 4 + FOUR_BYTES_MAX_VALUE;
4242

43-
private MqttVariableByteInteger() {}
44-
4543
/**
4644
* Decodes a variable byte integer from the given byte buffer at the current reader index.
4745
* <p>
@@ -128,4 +126,6 @@ public static int encodedLength(final int value) {
128126
}
129127
return length;
130128
}
129+
130+
private MqttVariableByteInteger() {}
131131
}

src/main/java/com/hivemq/client/internal/mqtt/exceptions/MqttClientStateExceptions.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
/**
2424
* @author Silvio Giebl
2525
*/
26-
public class MqttClientStateExceptions {
26+
public final class MqttClientStateExceptions {
2727

2828
public static @NotNull MqttClientStateException notConnected() {
2929
return new MqttClientStateException("MQTT client is not connected.");
@@ -32,4 +32,6 @@ public class MqttClientStateExceptions {
3232
public static @NotNull MqttClientStateException alreadyConnected() {
3333
return new MqttClientStateException("MQTT client is already connected or connecting.");
3434
}
35+
36+
private MqttClientStateExceptions() {}
3537
}

src/main/java/com/hivemq/client/internal/mqtt/handler/disconnect/MqttDisconnectUtil.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*
3232
* @author Silvio Giebl
3333
*/
34-
public class MqttDisconnectUtil {
34+
public final class MqttDisconnectUtil {
3535

3636
/**
3737
* Closes the channel from the client side without sending a DISCONNECT message.
@@ -97,4 +97,6 @@ static void fireDisconnectEvent(
9797
channel.config().setAutoRead(false);
9898
channel.pipeline().fireUserEventTriggered(disconnectEvent);
9999
}
100+
101+
private MqttDisconnectUtil() {}
100102
}

0 commit comments

Comments
 (0)