Fixing issue with multiplicity=1 for simple type associations in Reader/Writer generators
- Understand the issue: when an association has multiplicity=1 and type is a simple type like String, generators incorrectly call parseString/writeString/updateString methods that don't exist
- Create test case to reproduce the issue
- Fix Xpp3ReaderGenerator to handle simple type associations with multiplicity=1
- Fix Xpp3WriterGenerator to handle simple type associations with multiplicity=1
- Fix SnakeYamlReaderGenerator to handle simple type associations with multiplicity=1
- Fix SnakeYamlWriterGenerator to handle simple type associations with multiplicity=1
- Fix StaxReaderGenerator to handle simple type associations with multiplicity=1
- Fix StaxWriterGenerator to handle simple type associations with multiplicity=1
- Fix JDOMWriterGenerator to handle simple type associations with multiplicity=1
- Verify all tests pass
- Rebased on master and resolved conflicts with Root -> rootElement rename
Summary
The issue was that when an association field has multiplicity="1" and the type is a simple type (like String), the code generators incorrectly tried to call methods like parseString(), writeString(), and updateString() which don't exist.
Root Cause
The generators assumed all associations with multiplicity="1" were references to model classes and generated calls to parseClassName() or writeClassName() methods. They didn't account for simple types like String which are allowed in associations but aren't model classes.
Solution
Added a check in all affected generators to determine if the association type is a class in the model using isClassInModel(). If it's not a model class, the code now uses the primitive field handling logic instead.
Rebase on Master
- Successfully rebased on latest master (commit bca1253)
- Resolved conflict in JDOMWriterGenerator.java where
root variable was renamed to rootElement
- All tests pass after rebase
Original prompt
This section details on the original issue you should resolve
<issue_title>multiplicity with 1 for simple type generate wrong code in Reader/Writer</issue_title>
<issue_description>Eg for field type of String we have used method like:
- parseString
- writeString
- updateString
which is not defined
to reproduce use:
<field>
<name>listField</name>
<type>List</type>
<association>
<type>String</type>
<multiplicity>1</multiplicity>
</association>
</field>
```</issue_description>
## Comments on the Issue (you are @copilot in this section)
<comments>
</comments>
Fixes #403
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.