Skip to content

2.0 fixes and enhancements#2

Merged
perNyfelt merged 4 commits intomasterfrom
2.0-fixes_and_enhancements
Feb 26, 2026
Merged

2.0 fixes and enhancements#2
perNyfelt merged 4 commits intomasterfrom
2.0-fixes_and_enhancements

Conversation

@perNyfelt
Copy link
Member

This pull request introduces several improvements and refactorings across the codebase, focusing on API modernization, code simplification, and enhanced error handling. The most significant changes are the conversion of public fields in SieDocumentReader to private fields with accessor methods, improvements to encoding and I/O utilities, and more robust exception handling.

API modernization and encapsulation:

  • Refactored SieDocumentReader by replacing public fields with private fields and adding getter/setter methods for all configuration options, callbacks, and state. This improves encapsulation and makes the API more idiomatic and maintainable.
  • Updated usage throughout the codebase to access callbacks and configuration via the new accessor methods rather than direct field access. [1] [2] [3]

Encoding and I/O improvements:

  • Simplified Encoding utility: removed unnecessary imports and logging, changed getBytes to return a byte array instead of a collection, and updated consumers to use the new signature. [1] [2] [3]
  • Refactored IoUtil to remove legacy code and streamline reader/writer creation, ensuring files are always created or truncated appropriately. [1] [2] [3]

Checksum and comparison logic:

  • Updated SieCRC32 to use the new encoding utilities, simplifying buffer handling and improving performance. [1] [2] [3]
  • Improved currency comparison in SieDocumentComparer by using a utility method for null-safe equality checks, and clarified the behavior of SieDocument.getVALUTA to return null when not set. [1] [2]

Error handling enhancements:

  • Added constructors to SieDateException and MissingFieldException that accept a cause, enabling better exception chaining and debugging. [1] [2]
  • Fixed a typo in SieVoucherMismatchException and updated developer documentation.

CI/CD automation:

  • Added a new GitHub Actions workflow for CI, including build and test report artifact upload.

perNyfelt and others added 3 commits February 26, 2026 21:37
- Fix IoUtil.getWriter() file corruption bug (WRITE without TRUNCATE_EXISTING)
- Fix #ADRESS writing literal "null" for null subfields (now writes "")
- Normalize getVALUTA() to return null when unset, matching other getters
- Fix null-safety in SieDocumentComparer for VALUTA comparison
- Rename SieVoucherMissmatchException to SieVoucherMismatchException
- Encapsulate all public fields on SieDocumentReader with getters/setters
- Wrap JAXBException in SieException in SIE 5 reader/writer public API
- Remove dead commented-out code in IoUtil, Encoding, and SiePeriodValue
- Remove redundant file.delete() in SieDocumentWriter.write()
- Update README, DEVELOPER.md, and tests for API changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nd new tests

- Wrap date parsing in SieDataItem.getDate() with try-catch for DateTimeException
- Make Encoding.defaultCharset final and remove unused logger field
- Add cause constructors to all 8 exception classes for proper exception chaining
- Add 7 new tests covering ignoreRTRANS, streamValues, constructor params,
  invalid file detection, throwErrors collection, and invalid date handling

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…toring

Add GitHub Actions CI workflow for build/test on push/PR to master.
Eliminate Byte boxing in Encoding.getBytes() and SieCRC32 by using byte[]
directly. Refactor SieDocumentReader to replace 35-branch if/else chain
with a Map<String, Consumer<SieDataItem>> dispatch table.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 26, 2026 21:11
The *.jar gitignore rule was excluding the Gradle wrapper jar needed
by CI. Add a negation rule and track the wrapper jar.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request modernizes the SIE parser API by improving encapsulation, simplifying utilities, and enhancing error handling. The primary changes convert public configuration fields in SieDocumentReader to private fields with accessor methods, refactor parsing logic from if-else chains to a handler map pattern, and add exception constructors that accept causes for better exception chaining.

Changes:

  • Converted SieDocumentReader public fields to private with getter/setter methods, improving API encapsulation
  • Simplified Encoding and IoUtil utilities by removing legacy code and changing getBytes() to return byte arrays
  • Added cause-accepting constructors to multiple exception classes for better exception chaining
  • Fixed typo: renamed SieVoucherMissmatchException to SieVoucherMismatchException
  • Added GitHub Actions CI workflow for automated builds and testing

Reviewed changes

Copilot reviewed 24 out of 26 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/main/java/alipsa/sieparser/SieDocumentReader.java Converted public fields to private with getters/setters; refactored parsing logic to use handler map pattern
src/test/java/alipsa/sieparser/SieDocumentReaderTest.java Updated tests to use new accessor methods; added comprehensive tests for streaming, error handling, and invalid dates
src/test/java/alipsa/sieparser/TestSieDocument.java Updated to use new setIgnoreMissingOMFATTNING() method
src/main/java/alipsa/sieparser/Encoding.java Simplified by removing logging and changing getBytes() to return byte[] instead of Collection
src/main/java/alipsa/sieparser/IoUtil.java Removed legacy commented code; simplified getWriter() to use CREATE and TRUNCATE_EXISTING options
src/main/java/alipsa/sieparser/SieCRC32.java Updated to use new byte[] signature from Encoding.getBytes()
src/main/java/alipsa/sieparser/SieDocumentWriter.java Removed manual file deletion (handled by IoUtil); improved ADRESS field handling with nullToEmpty helper
src/main/java/alipsa/sieparser/SieDocumentComparer.java Changed VALUTA comparison to use null-safe StringUtil.equals()
src/main/java/alipsa/sieparser/SieDocument.java Updated getVALUTA() documentation to clarify it returns null when not set
src/main/java/alipsa/sieparser/SieDataItem.java Improved date parsing with try-catch for DateTimeException; updated to use getCallbacks() accessor
src/main/java/alipsa/sieparser/SieVoucherMismatchException.java Fixed class name typo (Missmatch → Mismatch); added constructor accepting cause
src/main/java/alipsa/sieparser/SieDateException.java Added constructor accepting cause for exception chaining
src/main/java/alipsa/sieparser/MissingFieldException.java Added constructor accepting cause for exception chaining
src/main/java/alipsa/sieparser/SieMissingObjectException.java Added constructor accepting cause for exception chaining
src/main/java/alipsa/sieparser/SieMissingMandatoryDateException.java Added constructor accepting cause for exception chaining
src/main/java/alipsa/sieparser/SieInvalidFileException.java Added constructor accepting cause for exception chaining
src/main/java/alipsa/sieparser/SieInvalidFeatureException.java Added constructor accepting cause for exception chaining
src/main/java/alipsa/sieparser/SieInvalidChecksumException.java Added constructor accepting cause for exception chaining
src/main/java/alipsa/sieparser/sie5/Sie5DocumentReader.java Changed methods to throw SieException instead of JAXBException with proper error messages
src/main/java/alipsa/sieparser/sie5/Sie5DocumentWriter.java Changed methods to throw SieException instead of JAXBException with proper error messages
src/main/java/alipsa/sieparser/SiePeriodValue.java Removed commented-out legacy code
docs/DEVELOPER.md Fixed class name typo in documentation
README.md Updated examples to use new accessor methods
.github/workflows/ci.yml Added GitHub Actions CI workflow for automated testing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@perNyfelt perNyfelt merged commit 42aee66 into master Feb 26, 2026
1 check passed
@perNyfelt perNyfelt deleted the 2.0-fixes_and_enhancements branch February 26, 2026 21:30
Copilot AI mentioned this pull request Feb 27, 2026
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.

2 participants