Skip to content

Commit c066b66

Browse files
committed
Merge pull request #77 from DevFactory/release/utility-classes-should-not-have-public-constructor-fix-1
Code quality fix - Utility classes should not have public constructors.
2 parents 4125d50 + d6d2f16 commit c066b66

File tree

13 files changed

+50
-0
lines changed

13 files changed

+50
-0
lines changed

src/main/java/io/reactivesocket/Frame.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ public void wrap(final int streamId, final FrameType type, final ByteBuffer data
257257
// SETUP specific getters
258258
public static class Setup
259259
{
260+
261+
private Setup() {}
262+
260263
public static Frame from(
261264
int flags,
262265
int keepaliveInterval,
@@ -317,6 +320,9 @@ public static String dataMimeType(final Frame frame)
317320

318321
public static class Error
319322
{
323+
324+
private Error() {}
325+
320326
public static Frame from(
321327
int streamId,
322328
final Throwable throwable,
@@ -360,6 +366,8 @@ public static int errorCode(final Frame frame)
360366

361367
public static class Lease
362368
{
369+
private Lease() {}
370+
363371
public static Frame from(int ttl, int numberOfRequests, ByteBuffer metadata)
364372
{
365373
final Frame frame = POOL.acquireFrame(LeaseFrameFlyweight.computeFrameLength(metadata.remaining()));
@@ -383,6 +391,8 @@ public static int numberOfRequests(final Frame frame)
383391

384392
public static class RequestN
385393
{
394+
private RequestN() {}
395+
386396
public static Frame from(int streamId, int requestN)
387397
{
388398
final Frame frame = POOL.acquireFrame(RequestNFrameFlyweight.computeFrameLength());
@@ -400,6 +410,8 @@ public static long requestN(final Frame frame)
400410

401411
public static class Request
402412
{
413+
private Request() {}
414+
403415
public static Frame from(int streamId, FrameType type, Payload payload, int initialRequestN)
404416
{
405417
final ByteBuffer d = payload.getData() != null ? payload.getData() : NULL_BYTEBUFFER;
@@ -473,6 +485,9 @@ public static boolean isRequestChannelComplete(final Frame frame)
473485

474486
public static class Response
475487
{
488+
489+
private Response() {}
490+
476491
public static Frame from(int streamId, FrameType type, Payload payload)
477492
{
478493
final ByteBuffer data = payload.getData() != null ? payload.getData() : NULL_BYTEBUFFER;
@@ -507,6 +522,9 @@ public static Frame from(int streamId, FrameType type)
507522

508523
public static class Cancel
509524
{
525+
526+
private Cancel() {}
527+
510528
public static Frame from(int streamId)
511529
{
512530
final Frame frame =
@@ -520,6 +538,9 @@ public static Frame from(int streamId)
520538

521539
public static class Keepalive
522540
{
541+
542+
private Keepalive() {}
543+
523544
public static Frame from(ByteBuffer data, boolean respond)
524545
{
525546
final Frame frame =

src/main/java/io/reactivesocket/FrameType.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public enum FrameType
4747

4848
private static class Flags
4949
{
50+
private Flags() {}
51+
5052
private static final int CAN_HAVE_DATA = 0b0001;
5153
private static final int CAN_HAVE_METADATA = 0b0010;
5254
private static final int CAN_HAVE_METADATA_AND_DATA = 0b0011;

src/main/java/io/reactivesocket/exceptions/Exceptions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
import static java.nio.charset.StandardCharsets.UTF_8;
2424

2525
public class Exceptions {
26+
27+
private Exceptions() {}
28+
2629
public static Throwable from(Frame frame) {
2730
final int errorCode = Frame.Error.errorCode(frame);
2831
String message = "<empty message>";

src/main/java/io/reactivesocket/internal/PublisherUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434

3535
public class PublisherUtils {
3636

37+
private PublisherUtils() {}
38+
3739
// TODO: be better about using scheduler for this
3840
public static final ScheduledExecutorService SCHEDULER_THREAD = Executors.newScheduledThreadPool(1,
3941
(r) -> {

src/main/java/io/reactivesocket/internal/frame/ByteBufferUtil.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
public class ByteBufferUtil
2121
{
22+
23+
private ByteBufferUtil() {}
24+
2225
/**
2326
* Slice a portion of the {@link ByteBuffer} while preserving the buffers position and limit.
2427
*

src/main/java/io/reactivesocket/internal/frame/ErrorFrameFlyweight.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
import java.nio.ByteOrder;
3333

3434
public class ErrorFrameFlyweight {
35+
36+
private ErrorFrameFlyweight() {}
37+
3538
// defined error codes
3639
public static final int INVALID_SETUP = 0x0001;
3740
public static final int UNSUPPORTED_SETUP = 0x0002;

src/main/java/io/reactivesocket/internal/frame/FrameHeaderFlyweight.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
*/
3838
public class FrameHeaderFlyweight
3939
{
40+
41+
private FrameHeaderFlyweight() {}
42+
4043
public static final ByteBuffer NULL_BYTEBUFFER = ByteBuffer.allocate(0);
4144

4245
public static final int FRAME_HEADER_LENGTH;

src/main/java/io/reactivesocket/internal/frame/KeepaliveFrameFlyweight.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
public class KeepaliveFrameFlyweight
2525
{
26+
private KeepaliveFrameFlyweight() {}
27+
2628
private static final int PAYLOAD_OFFSET = FrameHeaderFlyweight.FRAME_HEADER_LENGTH;
2729

2830
public static int computeFrameLength(final int dataLength)

src/main/java/io/reactivesocket/internal/frame/LeaseFrameFlyweight.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
public class LeaseFrameFlyweight
2727
{
28+
private LeaseFrameFlyweight() {}
29+
2830
// relative to start of passed offset
2931
private static final int TTL_FIELD_OFFSET = FrameHeaderFlyweight.FRAME_HEADER_LENGTH;
3032
private static final int NUM_REQUESTS_FIELD_OFFSET = TTL_FIELD_OFFSET + BitUtil.SIZE_OF_INT;

src/main/java/io/reactivesocket/internal/frame/RequestFrameFlyweight.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525

2626
public class RequestFrameFlyweight
2727
{
28+
29+
private RequestFrameFlyweight() {}
30+
2831
public static final int FLAGS_REQUEST_CHANNEL_C = 0b0001_0000_0000_0000;
2932
public static final int FLAGS_REQUEST_CHANNEL_N = 0b0000_1000_0000_0000;
3033

0 commit comments

Comments
 (0)