title: Set default value for fields not in XML in XStream
body: <p>Is there a way to create a converter or some operation that is performed after every single conversion? For context, I am trying to populate default values for fields that are not in my XML in order to maintain backwards compatibility if my data model changes. For instance, if I had this object:</p>
  
  <pre><code>class A {
      private String b;
      private String c;
      private String d;
  }
  </code></pre>
  
  <p>and my XML was something like:</p>
  
  <pre><code>&lt;a&gt;
   &lt;b&gt;b&lt;/b&gt;
   &lt;d&gt;d&lt;/d&gt;
  &lt;/a&gt;
  </code></pre>
  
  <p>I want my import of the XML to know that there is a default value for the field <code>c</code> that is <code>"c"</code> and set it on <code>A</code> as such. This should be a generic operation to which I can add defaults to any field of a very complex graph. If there were some way to trigger a function after every conversion, it could check the current object against a map of objects I'd like to set a default value on.</p>
  
  <p>Also note, that using readResolve/readObject does not seem to be an option since 1. readObject() never seemed to work for me at all and 2. readResolve would overwrite the field with the default value even if it were actually included in the XML. Please let me know if my assumptions here are wrong though.</p>
  
  <p>Edit:: I found this related thread on the user mailing list:
  <a href="http://article.gmane.org/gmane.comp.java.xstream.user/4619/match=default+value" rel="noreferrer">http://article.gmane.org/gmane.comp.java.xstream.user/4619/match=default+value</a></p>
  
  <p>and it seems like the only suggested solution is to use <code>readResolve()</code> which I already said was not a valid solution.</p>