Skip to content

Commit

Permalink
Make some Java classes proper utilities
Browse files Browse the repository at this point in the history
Made the design cleaner by marking Java classes as `final`
and explicitly declaring their default constructors as `private`.
This change makes the code coverage reports more accurate.
Closes #4926.
  • Loading branch information
vil02 committed Oct 18, 2023
1 parent 6b3dbf5 commit f078983
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 9 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Changed
- [Make some of the Java classes proper utility classes](https://github.com/ballerina-platform/ballerina-standard-library/issues/4926)

## [1.9.1] - 2023-10-12

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
/**
* Compiler-plugin utility class.
*/
public class Utils {
public final class Utils {

private Utils() {}

public static final String NODE_LOCATION = "node.location";
public static final String LS = System.lineSeparator();
Expand Down
4 changes: 3 additions & 1 deletion native/src/main/java/io/ballerina/stdlib/udp/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
/**
* Constant variable for udp related operations.
*/
public class Constants {
public final class Constants {

private Constants() {}

// Constant related to ballerina Datagram record
public static final String DATAGRAM_RECORD = "Datagram";
Expand Down
4 changes: 3 additions & 1 deletion native/src/main/java/io/ballerina/stdlib/udp/Dispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
/**
* Dispatch async methods.
*/
public class Dispatcher {
public final class Dispatcher {

private Dispatcher() {}

private static final Logger log = LoggerFactory.getLogger(Dispatcher.class);

Expand Down
4 changes: 3 additions & 1 deletion native/src/main/java/io/ballerina/stdlib/udp/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
*
* @since 0.985.0
*/
public class Utils {
public final class Utils {

private Utils() {}

/**
* udp standard library package ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
*
* @since 1.1.0
*/
public class Client {
public final class Client {

private Client() {}

public static Object init(Environment env, BObject client, BMap<BString, Object> config) {
final Future balFuture = env.markAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
*
* @since 1.1.0
*/
public class ConnectClient {
public final class ConnectClient {

private ConnectClient() {}

public static Object init(Environment env, BObject client, BString remoteHost,
int remotePort, BMap<BString, Object> config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
/**
* Native function implementations of the UDP Caller.
*/
public class Caller {
public final class Caller {

private Caller() {}

public static Object sendBytes(Environment env, BObject caller, BArray data) {
final Future callback = env.markAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
/**
* Native function implementations of the UDP Listener.
*/
public class Listener {
public final class Listener {
private Listener() {}

private static final Logger log = LoggerFactory.getLogger(Client.class);

public static Object init(BObject listener, int localPort, BMap<BString, Object> config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
/**
* This UDP server udp will use to mock the backend server.
*/
public class MockServerUtils {
public final class MockServerUtils {

private MockServerUtils() {}

private static MockUdpServer mockUdpServer;

Expand Down

0 comments on commit f078983

Please sign in to comment.