Skip to content

Add final modifier and private constructor for JsonReader#14344

Merged
Siedlerchr merged 2 commits into
JabRef:mainfrom
Nakul-Shivaraj:final-json-reader
Nov 19, 2025
Merged

Add final modifier and private constructor for JsonReader#14344
Siedlerchr merged 2 commits into
JabRef:mainfrom
Nakul-Shivaraj:final-json-reader

Conversation

@Nakul-Shivaraj

@Nakul-Shivaraj Nakul-Shivaraj commented Nov 18, 2025

Copy link
Copy Markdown
Contributor

Closes #14346

Added final modifier and private constructor to JsonReader utility class to prevent instantiation and subclassing, following Java best practices for utility classes containing only static methods.

@espertusnu - This addresses the utility class refactoring discussed on Gitter.

Steps to test

  1. Build the project: ./gradlew build
  2. Run existing tests: ./gradlew test
  3. Verify all tests pass - no functionality should be affected

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • [/] I manually tested my changes in running JabRef (always required)
  • [/] I added JUnit tests for changes (if applicable)
  • [/] I added screenshots in the PR description (if change is visible to the user)
  • [/] I described the change in CHANGELOG.md in a way that is understandable for the average user (if change is visible to the user)
  • [/] I checked the user documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request updating file(s) in https://github.com/JabRef/user-documentation/tree/main/en.

@InAnYan

InAnYan commented Nov 18, 2025

Copy link
Copy Markdown
Member

Is your PR work in progress? Because I see changes only for 1 class

public final class JsonReader {

private JsonReader() {
throw new UnsupportedOperationException("Utility class");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new UnsupportedOperationException("Utility class");
throw new UnsupportedOperationException("Cannot instantiate a utility class");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you apply this change to other PRs as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @InAnYan

Thank you for the review and suggestion! I'll update the error message in all the PRs.

@koppor

koppor commented Nov 18, 2025

Copy link
Copy Markdown
Member

Is your PR work in progress? Because I see changes only for 1 class

It was discussed on gitter. I did see that it are only four lines which changed; and therefore asked for different PRs for each class. --> See answer to https://matrix.to/#/!FrLnwBcqmXcZxTMyJj:gitter.im/$U5RLcIJU695KPAp9A1MKmnSkpyjUYyrL0QiRIIz6hgI?via=gitter.im&via=matrix.org&via=tchncs.de

The contributor could have asked, but he took 4 weeks to think and create all PRs at once.

@Nakul-Shivaraj

Copy link
Copy Markdown
Contributor Author

Hi @koppor,

Apologies for the delay in responding! I did create all 6 separate PRs as discussed on Gitter, all linked to issue #14346. I should have communicated this more clearly upfront - sorry for any confusion.

All PRs have been updated with the improved exception message as suggested by @InAnYan.

Thank you for your patience and guidance!

@Siedlerchr Siedlerchr added this pull request to the merge queue Nov 19, 2025
Merged via the queue into JabRef:main with commit c653bbc Nov 19, 2025
49 checks passed
merlinymy pushed a commit to merlinymy/jabref that referenced this pull request Nov 19, 2025
* Add final modifier and private constructor

* Update exception message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code Refactoring

4 participants