title: How to get input from Json using generic class?
body: <p>I want to write a generic class which inputs a Json file using the information in one field to determine what type of object is another field.</p>
  <p>for example, <code>Widget</code> object which has 2 fields: <code>type</code> <code>data</code> and <code>data</code> fields depends on <code>type</code></p>
  <p>if <code>type</code> is &quot;VideoPlayer&quot;, <code>data</code> should have &quot;Name&quot; &amp; &quot;Video&quot; and if <code>type</code> is &quot;Camera&quot;,<code>data</code> should have &quot;Address&quot; &amp; &quot;Input&quot;</p>
  <pre><code>public class Widget&lt;T&gt; {
  
      @JsonProperty(&quot;type&quot;)
      private String type;
  
      @JsonProperty(&quot;data&quot;)
      private Data&lt;T&gt; data;
  }
  </code></pre>