title: Implicit default values when deserializing JSON using Jackson
body: <p>When deserializing a variety of JSON messages, I want to provide a default value for attributes of a certain type. It is <a href="https://stackoverflow.com/a/18806773/147806">generally suggested</a> to simply specify the value in the Class, but this is error-prone if you have to do this across many Classes. You might forget one and end up with <code>null</code> instead of a default value. My intention is to set every property that is an <code>Optional&lt;T&gt;</code> to <code>Optional.absent</code>. Since <code>null</code> is exactly what <code>Optional</code> is trying to eliminate, using them with Jackson has proven to be frustrating.</p>
  
  <p>Most features of Jackson that allow you to customize the deserialization process focus on the JSON that is the input, not around the process of instantiating the Object that you are deserializing into. The closest I seem to be getting to a general solution is by building my own <code>ValueInstantiator</code>, but there are two remaining issues I have:</p>
  
  <ul>
  <li>how do I make it only instantiate <code>Optional</code> as <code>absent</code> but not interfere with the rest of the instantiation process?</li>
  <li>how do I wire the end result into my <code>ObjectMapper</code>?</li>
  </ul>
  
  <p><strong>UPDATE:</strong> I want to clarify that I am looking for a solution that does <em>not</em> involve modifying <em>each</em> Class that contains <code>Optional</code>'s. I'm opposed to violating the DRY principle. Me or my colleagues should not have to think about having to do something extra every time we add <code>Optional</code>'s to a new or existing Class. I want to be able to say, "make every Optional field in every Class I deserialize into, pre-filled with <code>Absent</code>", only once, and be done with it.</p>
  
  <p>That means the following are out:</p>
  
  <ul>
  <li>abstract parent class (need to declare)</li>
  <li>custom Builder/Creator/JsonDeserializer (needs annotation on each applicable class)</li>
  <li>MixIn's? I tried this, combined with reflection, but I don't know how to access the Class I'm being mixed into...</li>
  </ul>