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 #4929.
  • Loading branch information
vil02 committed Oct 18, 2023
1 parent 737b0fe commit 3439afd
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 6 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ This file contains all the notable changes done to the Ballerina Constraint pack

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

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

## [1.2.0] - 2023-06-01

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
/**
* The constants related to compiler plugin tests.
*/
public class CompilerPluginTestConstants {
public final class CompilerPluginTestConstants {

private CompilerPluginTestConstants() {}

static final String ANNOTATION_TAG_INT = "Int";
static final String ANNOTATION_TAG_FLOAT = "Float";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
/**
* Utility functions related to compiler plugins tests.
*/
public class CompilerPluginTestUtils {
public final class CompilerPluginTestUtils {

private CompilerPluginTestUtils() {}

private static final Path RESOURCE_DIRECTORY = Paths.get("src", "test", "resources", "ballerina_sources")
.toAbsolutePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
/**
* The constants related to compiler plugin.
*/
public class Constants {
public final class Constants {

private Constants() {}

public static final String PACKAGE_NAME = "ballerina";
public static final String MODULE_NAME = "constraint";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@
/**
* The compiler plugin utility functions.
*/
public class ConstraintCompilerPluginUtils {
public final class ConstraintCompilerPluginUtils {

private ConstraintCompilerPluginUtils() {}

private static final ConstraintCompatibilityMatrix matrix = new ConstraintCompatibilityMatrix();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
/**
* Constants related to constraint module.
*/
public class Constants {
public final class Constants {

private Constants() {}

public static final String PREFIX_RECORD_FIELD = "$field$";
public static final String ANNOTATION_RECORD_REGEX = "^ballerina/constraint:[0-9]+:.+";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
/**
* Utility functions related to errors.
*/
public class ErrorUtils {
public final class ErrorUtils {

private ErrorUtils() {}

private static final String UNEXPECTED_ERROR_MESSAGE = "Unexpected error found due to typedesc and value mismatch.";
private static final String TYPE_CONVERSION_ERROR_MESSAGE = "Type conversion failed due to typedesc and value " +
Expand Down

0 comments on commit 3439afd

Please sign in to comment.