title: Conversion headache
body: <p>I'm in front of a task of converting XML nodes to JPA entities. Objects in the XML are similar to those represented by the entities, but not exactly the same. It seems there will be much of conversion code ahead of me.</p>
  
  <p>XML is defined in Schema .xsd file and I'm using JAXB to generate the classes and create instances. The decision from above is not to touch the generated types. I will create converters for each of them, maybe I'll go with visitor pattern, don't know yet.</p>
  
  <p>What troubles me is a situation in which someone decides to alter the .xsd file and will not update the responsible converter.</p>
  
  <p>My idea is to make those converter classes maintain a static final list of fields from appropriate JAXB class that are handled in the code. Should anybody alter them in the .xsd file, some warning would be logged that some fields are not handled yet, or some handled fields don't exist anymore.</p>
  
  <p>Additionally, I would like to ensure that the number of converters matches the number of JAXB generated classes. <strong>How to do that?</strong></p>
  
  <p><em>Maybe I should somehow check in the execution time what classes can be generated from the .xsd file and compare them with the registered converters. I feel I cannot just scan classes in a specific package to check the JAXB output classes.</em></p>
  
  <p><em>Maybe the visitor pattern could tell me what went wrong, but it would probably be a bad idea to prolong the check till the error in XML-JPA conversion happens in practice.</em></p>