title: Deep Mapping with Providers and Immutable Objects
body: <p>I have a model like this:</p>
  
  <pre><code>public class PersonDto {
  
      private CarDto car;
  
      public CarDto getCar() {
          return car;
      }
  
      public void setCar(CarDto car) {
          this.car = car;
      }
  
      public static class CarDto {
  
          private String model;
  
          private String color;
  
          public String getModel() {
              return model;
          }
  
          public void setModel(String model) {
              this.model = model;
          }
  
          public String getColor() {
              return color;
          }
  
          public void setColor(String color) {
              this.color = color;
          }
      }
  }
  </code></pre>
  
  <p>And the VO is immutable:</p>
  
  <pre><code>public class PersonVo {
  
      private final CarDto car;
  
      public PersonVo(CarDto car) {
          super();
          this.car = car;
      }
  
      public CarDto getCar() {
          return car;
      }
  
      public static class CarDto {
  
          private final String model;
  
          private final String color;
  
          public CarDto(String model, String color) {
              super();
              this.model = model;
              this.color = color;
          }
  
          public String getModel() {
              return model;
          }
  
          public String getColor() {
              return color;
          }   
      }
  }
  </code></pre>
  
  <p>Is there an easy way using <code>ModelMapper</code> Providers to convert this scenario from Dto to Vo?</p>
  
  <p>I can't figure it out using one provider for <code>PersonVo</code> because when I'm creating the new object I don't know how to parse the <code>CarDto</code>...</p>
  
  <pre><code>public class PersonVoProvider implements Provider&lt;PersonVo&gt; {
  
      public PersonVo get(org.modelmapper.Provider.ProvisionRequest&lt;PersonVo&gt; request) {
          PersonDto source = PersonDto.class.cast(request.getSource());
          return new PersonVo(car); ????????????
      }
  }
  </code></pre>