title: How to copy content of generic object for specific object
body: <p>I need a support in this code, I have a method that I get generic object and a String, so according to the String I get I want to copy the contents of the generic object to
  specific object, one observation that Object TypeA don't have same fields that TypeB. for example:</p>
  
  <p>Thanks in advance</p>
  
  <pre><code>@POST
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  @Authorize("Receiving")
  @Path("/Print")
  
  public Response LabelPrint(@Context HttpServletRequest request, 
                              final Object generic
                             ,@QueryParam("Type") final String Type) {
  
      if ( Typex.compareTo("X")) {
  
          TypeA typeA = generic;
          ...
  
      } else {
          TypeB typeB = generic;
          ...
      }
  
      return buildResponse(OK);   
  </code></pre>
  
  <p>}</p>
  
  <p>I tried that away, but unsuccessfully</p>
  
  <pre><code>    if (labelType.compareTo("X")) {             
          TypeA x = new TypeA();
          BeanUtils.copyProperties(x, generic);
      }
      else {
          TypeA y = new TypeA();
          BeanUtils.copyProperties(y, generic);
      }
  </code></pre>