Refactor encoders and normalizers, add utilities and tests, and enhance Gradle build#3
Merged
felipestanzani merged 5 commits intomainfrom Oct 30, 2025
Merged
Refactor encoders and normalizers, add utilities and tests, and enhance Gradle build#3felipestanzani merged 5 commits intomainfrom
felipestanzani merged 5 commits intomainfrom
Conversation
- Removed unused constants from the Constants class, including PIPE, NEWLINE, CARRIAGE_RETURN, and TAB. - Deleted redundant encode methods from the JToon class to streamline the encoding process. - Introduced a comprehensive unit test suite for the JsonNormalizer utility, covering various input types and edge cases, ensuring robust functionality and correctness.
- Replaced traditional if-else statements with switch expressions for better clarity and conciseness in the normalize method and its helper functions. - Updated the ProjectRootManager's language level in the IDE configuration from JDK_25 to JDK_21.
…n for normalization - Introduced a list of normalization functions to streamline the normalization process for various data types. - Replaced multiple conditional checks with a functional approach, enhancing readability and maintainability. - Updated normalization methods for primitives, big numbers, and temporal types to improve clarity and efficiency.
- Simplified encoding methods by utilizing Java 21 switch expressions for primitive values. - Delegated validation and escaping responsibilities to StringValidator and StringEscaper. - Updated header formatting to use HeaderFormatter for improved modularity and readability. - Removed unused regex patterns and redundant methods to streamline the class structure.
- Applied external Gradle scripts for publishing and verification to streamline build processes. - Updated ProjectRootManager's language level to JDK_25 for improved compatibility. - Introduced new encoding utilities, including ArrayEncoder, ObjectEncoder, and LineWriter, to enhance the encoding process for TOON format. - Added JsonNormalizer for normalizing Java objects to Jackson JsonNode representation, supporting various data types. - Implemented utility classes for string validation and escaping to ensure proper formatting in TOON output. - Added comprehensive unit tests for encoding and normalization functionalities to ensure robustness and correctness.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR restructures the
jtoonpackage into clearer subpackages, introduces new utilities, significantly expands test coverage, and improves the Gradle build with publishing and verification. It also refactors several core components for readability, maintainability, and performance.Changes
Constantstoutil(src/main/java/com/felipestanzani/jtoon/util/Constants.java).encoderpackage:ArrayEncoder,ListItemEncoder,ObjectEncoder,PrimitiveEncoder,TabularArrayEncoder,ValueEncoder,HeaderFormatter,LineWriter(moved).normalizerpackage:JsonNormalizerand package docs.JToon.javato align with refactors.JsonNormalizer.java(old path),PrimitiveEncoder.java(old path),ValueEncoder.java(old path).package-info.javafiles forjtoon,encoder,normalizer, andutil.StringEscaperandStringValidatorunderutil.HeaderFormatterTest,JsonNormalizerTest,LineWriterTest,PrimitiveEncoderTest,StringEscaperTest,StringValidatorTest.build.gradle.gradle/publishing.gradleandgradle/verification.gradlefor publishing and verification configurations..idea/dictionaries/project.xml(note: typically excluded; see Notes).Commits
Motivation
Impact and Compatibility
com.felipestanzani.jtoon.Constants→com.felipestanzani.jtoon.util.Constantscom.felipestanzani.jtoon.encoder.*com.felipestanzani.jtoon.normalizer.*Migration Guide
Constants→com.felipestanzani.jtoon.util.Constantscom.felipestanzani.jtoon.encoder.*JsonNormalizer→com.felipestanzani.jtoon.normalizer.JsonNormalizerLineWriter, usecom.felipestanzani.jtoon.encoder.LineWriter.StringEscaperandStringValidatorfromutilwhere applicable.Testing
CI/CD and Publishing
publishing.gradleconfigures artifact publishing.verification.gradleconfigures additional verification tasks.check,test, and publishing dry-runs as needed.Documentation
package-info.javaadded across key packages to clarify responsibilities.build/docs/javadoc.Notes
.idea/dictionaries/project.xmlis added; typically IDE files are excluded via.gitignore. If undesired in VCS, I can remove it from this PR and update.gitignore.Checklist
package-info.java.idea) or remove from PRRelease Notes
com.felipestanzani.jtoon.encoder.*, normalizer tocom.felipestanzani.jtoon.normalizer.*, constants tocom.felipestanzani.jtoon.util.Constants.StringEscaperandStringValidatorutilities.