title: Jackson deserializer - change null collection to empty one
body: <p>I have an entity that contains collection as attribute:</p>
  
  <pre><code>public class Entity {
  
      @JsonProperty(value="homes")
      @JsonDeserialize(as=HashSet.class, contentAs=HomeImpl.class)
      private Collection&lt;Home&gt; homes = new ArrayList&lt;Home&gt;();
  
  }
  </code></pre>
  
  <p>If request contains null as request property:</p>
  
  <pre><code>{
    "homes": null
  }
  </code></pre>
  
  <p>then homes is set to null. What I want to do is to set homes to empty list. Do I need to write special deserializer for this or is there one for collections? What I tried is this deserializer but it looks ugly (it's not generic and uses implementation instead of interface).</p>
  
  <pre><code>public class NotNullCollectionDeserializer extends JsonDeserializer&lt;Collection&lt;HomeImpl&gt;&gt; {
  
    @Override
    public Collection&lt;HomeImpl&gt; deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
      return jsonParser.readValueAs(new TypeReference&lt;Collection&lt;HomeImpl&gt;&gt;(){});
    }
  
    @Override
    public Collection&lt;HomeImpl&gt; getNullValue() {
      return Collections.emptyList();
    }
  }
  </code></pre>
  
  <p>So few questions:</p>
  
  <ol>
  <li>Is there some jackson property that changes null to empty collection during deserialization?</li>
  <li>If no for the first point - do I need to write deserializer for this? If yes, can I write generic one?</li>
  </ol>