Skip to content

Fix ClassCastExeption + improve compatibleConstructor detection#22

Merged
Maxlego08 merged 3 commits intoGroupeZ-dev:developfrom
1robie:develop
Apr 3, 2026
Merged

Fix ClassCastExeption + improve compatibleConstructor detection#22
Maxlego08 merged 3 commits intoGroupeZ-dev:developfrom
1robie:develop

Conversation

@1robie
Copy link
Copy Markdown

@1robie 1robie commented Apr 3, 2026

This pull request strengthens type safety and constructor compatibility checks in the schema and DTO consumer logic. The main improvements include stricter validation of object types when adding schema columns, enhanced handling of overloaded constructors, and additional unit tests to verify these behaviors.

Type validation improvements

  • Added explicit type checks and error handling in schemaFromType to ensure that objects passed for schema column values match the expected type (e.g., Number for numeric types, Boolean for booleans, UUID for UUID columns, and Date for date columns). Throws clear IllegalArgumentException messages when mismatches occur. [1] [2]

Constructor compatibility enhancements

  • Updated createConsumerFromTemplate to check all constructors for compatibility with the DTO's fields, supporting overloaded constructors and ensuring that the number of non-synthetic constructor parameters matches the number of fields. Throws an exception if no compatible constructor is found.

Test coverage improvements

  • Added OverloadedTemplateDTO and IncompatibleTemplateDTO classes in test code to verify handling of overloaded and incompatible constructors.
  • Added unit tests to confirm that consumers can be created for DTOs with overloaded constructors and that an exception is thrown when no compatible constructor exists.

@Maxlego08 Maxlego08 merged commit 07e88ee into GroupeZ-dev:develop Apr 3, 2026
1 check passed
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