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 #4927.
  • Loading branch information
vil02 committed Oct 19, 2023
1 parent d686e95 commit a61d923
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- [Introduce new `ClientConfiguration` record to be used for `websub:SubscriptionClient` and `websub:DiscoveryService`](https://github.com/ballerina-platform/ballerina-standard-library/issues/4706)

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

## [2.9.1] - 2023-09-14

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
* {@code TestUtils} contains the utility methods for compiler plugin tests.
*/
public final class TestUtils {
private TestUtils() {}

private static final Path RESOURCE_PATH = Paths.get("src", "test", "resources");
private static final Path DISTRIBUTION_PATH = Paths
.get("../", "target", "ballerina-runtime").toAbsolutePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
* {@code CommonUtil} contains common utility functions related to compiler-plugin.
*/
public final class CommonUtil {
private CommonUtil() {}

public static Optional<AnnotationSymbol> extractSubscriberServiceConfig(ServiceDeclarationSymbol service) {
return service.annotations()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
* {@code CodeActionUtil} contains utility functions related to code-actions.
*/
public final class CodeActionUtil {
private CodeActionUtil() {}

/**
* Finds a node in syntax-tree by line-range.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
* {@code AnalyserUtils} contains utility functions required for {@code websub:SubscriberService} validation.
*/
public final class AnalyserUtils {
private AnalyserUtils() {}

public static void updateContext(SyntaxNodeAnalysisContext context, WebSubDiagnosticCodes errorCode,
NodeLocation location, Object... args) {
DiagnosticInfo diagnosticInfo = new DiagnosticInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
/**
* {@code NativeHttpToWebsubAdaptor} is a wrapper object used for service method execution.
*/
public class NativeHttpToWebsubAdaptor {
public final class NativeHttpToWebsubAdaptor {
private NativeHttpToWebsubAdaptor() {}

public static void externInit(BObject adaptor, BObject service) {
adaptor.addNativeData(SERVICE_OBJECT, service);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
/**
* {@code NativeWebSubListenerAdaptor} is a wrapper object used to save/retrieve native data related to WebSub Listener.
*/
public class NativeWebSubListenerAdaptor {
public final class NativeWebSubListenerAdaptor {
private NativeWebSubListenerAdaptor() {}

public static void externAttach(BObject websubListener, BString servicePath,
BObject subscriberService, BObject httpService,
BMap<BString, Object> subscriberConfig) {
Expand Down

0 comments on commit a61d923

Please sign in to comment.