title: How to handle parent child relation for Rest service
body: <p>In my Spring boot service, I have a controller as below</p>
  
  <pre class="lang-java prettyprint-override"><code>@PostMapping 
  public ApiResponse generateUKLabel(@RequestBody LabelRequestData data){
    //do operation
  }
  </code></pre>
  
  <p>Here, LabelRequestData has List of base class.
  In, request I am passing child class data with base class data.
  But, Child class data seems to be ignored.</p>
  
  <p>Is there any way I can access the child class data.
  I want to make the LabelRequestData with Base class generic so that it can accept multiple child class data.</p>
  
  <p>Is there any way to solve it?</p>
  
  <p>I tried casting. but throws can't cast exception 
  I also tried generics. but then I need to create two controller method to handle those request. I want only one controller method to handle the request</p>
  
  <pre><code>@Data
  public class LabelRequestData extends BaseRequestData {
  
      @Valid
      private List&lt;BaseClass&gt; labelData; // this base class has multiple child classes that i need
  
      @Valid
      private PreferenceData preferenceData;
  
  }
  </code></pre>