title: Generic Mapper function in MapStruct
body: <p>Friends,</p>
  <p>Here are my Java objects</p>
  <pre class="lang-java prettyprint-override"><code>@Data
  public class CarDto {
      private String make;
      private String model;
      private int year; 
  }
  
  @Data
  public class Car {
      private MakeEnum make;
      private String model;
      private int year;   
  }
  </code></pre>
  <p>For consuming, I need to do something like this</p>
  <pre class="lang-java prettyprint-override"><code>@Mapper
  public interface CarMapper {
     CarMapper INSTANCE = Mappers.getMapper(CarMapper.class);
     Car toModel(CarDto carDto);
     CarDto toDto(Car carModel);
  }
  
  // Using mapper
  Car carModel = CarMapper.INSTANCE.toModel(carDto);
  </code></pre>
  <p>But I am looking a solution, where I could do this:</p>
  <pre class="lang-java prettyprint-override"><code>  Car carModel = Mapper.map(carDto, Car.class);
  </code></pre>
  <p>How do do this? Didn't find an example where I can dynamically map based on a Type. I found this method very handy in both <code>ModelMapper</code> &amp; Google <code>gson</code>. Appreciate your help!</p>