How to create a custom deserializer in Jackson for a generic type?
<p>Imagine the following scenario:</p>

<pre><code>class &lt;T&gt; Foo&lt;T&gt; {
    ....
}

class Bar {
    Foo&lt;Something&gt; foo;
}
</code></pre>

<p>I want to write a custom Jackson deserializer for Foo. In order to do that (for example, in order to deserialize <code>Bar</code> class that has <code>Foo&lt;Something&gt;</code> property), I need to know the concrete type of <code>Foo&lt;T&gt;</code>, used in <code>Bar</code>, at deserialization time (e.g. I need to know that <code>T</code> is <code>Something</code> in that particluar case).</p>

<p>How does one write such a deserializer? It should be possible to do it, since Jackson does it with typed collections and maps.</p>

<p><strong>Clarifications:</strong></p>

<p>It seems there are 2 parts to solution of the problem:</p>

<p>1) Obtain declared type of property <code>foo</code> inside <code>Bar</code> and use that to deserialize <code>Foo&lt;Somehting&gt;</code></p>

<p>2) Find out at deserialization time that we are deserializing property <code>foo</code> inside class <code>Bar</code> in order to successfully complete step 1)</p>

<p>How does one complete 1 and 2 ?</p>