Background
During the implementation of Parameter and FunctionDefinition support in PR #319, @draeger suggested an architectural improvement for the AntimonySerializer. Currently, the serializer relies heavily on individual concrete class handling—specifically, an extensive instanceof routing chain and manual isSet...() checks for individual attributes.
Proposed Architecture
To reduce boilerplate and improve the scalability of the utility, we should leverage JSBML's existing abstraction mechanisms. By utilizing entry points like writeXMLAttributes or Java reflection (similar to JSBML's toString implementation), we can collect attribute/value pairs and structural information at a higher abstraction level.
For attributes or keywords that differ between SBML and Antimony, a simple mapping layer (such as a lookup table or properties-based configuration) can be introduced.
Implementation Goals
Benefits
- Reduces the number of class-specific special cases.
- Eliminates boilerplate attribute-checking code.
- Makes the serializer much easier to maintain and extend for future SBML components.
Background
During the implementation of
ParameterandFunctionDefinitionsupport in PR #319, @draeger suggested an architectural improvement for theAntimonySerializer. Currently, the serializer relies heavily on individual concrete class handling—specifically, an extensiveinstanceofrouting chain and manualisSet...()checks for individual attributes.Proposed Architecture
To reduce boilerplate and improve the scalability of the utility, we should leverage JSBML's existing abstraction mechanisms. By utilizing entry points like
writeXMLAttributesor Java reflection (similar to JSBML'stoStringimplementation), we can collect attribute/value pairs and structural information at a higher abstraction level.For attributes or keywords that differ between SBML and Antimony, a simple mapping layer (such as a lookup table or properties-based configuration) can be introduced.
Implementation Goals
SBaseelement.Compartment,Parameter, basicSpecies) to inherit their Antimony serialization almost entirely from the generic superclass logic.Reactionkinetic laws,Eventtriggers/assignments) that will still require custom override methods for nestedASTNodemath formatting.Benefits