feat: deprecate usage of singleton pattern#704
Conversation
|
Please check on sonarcloud https://sonarcloud.io/project/pull_requests_list?id=io.github.mivek%3AmetarParser that the PR does not add any issue. |
There was a problem hiding this comment.
Pull Request Overview
This PR removes the singleton pattern from various parser classes, making their constructors public for dependency injection and deprecating the old getInstance() methods. It also updates service constructors and factory mappings to use the new public constructors, and revises unit tests to instantiate parsers directly.
- Swapped all Parser.getInstance() calls for new Parser() in services, factories, and tests
- Made parser constructors public and annotated getInstance() as @deprecated (returning a new instance)
- Adjusted unit tests to construct parsers directly and added deprecated-method smoke tests
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| metarParser-services/.../AbstractWeatherCodeServiceTest.java | Removed unused Disabled import |
| metarParser-services/.../TAFService.java & MetarService.java | Updated services to call new Parser() instead of singleton |
| metarParser-parsers/.../TrendValididyParser.java & other parser classes | Made constructors public, deprecated singletons |
| metarParser-parsers/.../TafTrendParserFactory.java | Updated factory to instantiate fresh parser objects |
| Various parser *Test.java | Updated tests to use constructors and added testGetInstance methods |
Comments suppressed due to low confidence (1)
metarParser-parsers/src/test/java/io/github/mivek/parser/TAFParserTest.java:796
- The closing delimiter of the Java text block is on the same line as its content, which violates text block syntax. Move the closing
""";to its own line immediately after the content.
BECMG 2316/2317 34010G18KT 9999 NSW SCT170 QNH2969INS TX28/2323Z TN12/2314Z""";
Removed the singleton Pattern in the parsers.
cd64422 to
86f8f51
Compare
|
|
🎉 This PR is included in version 2.20.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |



Removed the singleton Pattern in the parsers.