title: Map Nested elements - Mapstruct
body: <p>I'm trying to map following source classes to target class using MapStruct.</p>
  <p>Target Classes :</p>
  <pre><code>public class Response {
      private List&lt;Customer&gt; customer = new ArrayList&lt;Customer&gt;();
  }
  
  public class Customer {
      private String customerId;
      private List&lt;Product&gt; products = new ArrayList&lt;Product&gt;();
  }
  
  public class CustProduct {
      private String CustProductId;
      private String CustPdtName;
      private List&lt;productDetail&gt; CustProductDetails = new ArrayList&lt;productDetail&gt;();
  }
  </code></pre>
  <p>Source Classes :</p>
  <pre><code>public class UserList {
      protected List&lt;User&gt; user;
  }
  
  public class User {
      protected String userId;
      protected List&lt;String&gt; productRefId;  //List of products for that particular user
  }
  
  public class ProductList {
      protected List&lt;Product&gt; product;
  }
  public class Product {
     protected String productId;       //Reference to productRefId
     protected String productName;
     protected List&lt;Details&gt; productDetails;
  }
     
  </code></pre>
  <p>Mapper Interface :</p>
  <pre><code> List&lt;Customer&gt; mapUser(List&lt;User&gt; user);
  
      @Mappings({
              @Mapping(target = &quot;customerId&quot;, source = &quot;userId”),
              @Mapping(target = &quot;products&quot;, ignore = true)
      })
      Customer mapUser(User user);
  
      @Mappings({
          @Mapping(target = &quot;CustProductId&quot;, source = &quot;productId&quot;),
          @Mapping(target = &quot;CustPdtName&quot;, source = &quot;productName&quot;),
          @Mapping(target = &quot;CustProductDetails&quot;, source = &quot;productDetails&quot;)
  })
  CustProduct mapUser(Product product);
  </code></pre>
  <p>My problem is, I want to connect <strong>CustProduct</strong> with <strong>Customer</strong>
  For that, I tried AfterMapping like :</p>
  <pre><code>default void findProducts(User user, @MappingTarget Customer customer) {
              List&lt;String&gt; productIds = user.getproductRefId();
              List&lt;CustProduct&gt; custProducts = new ArrayList&lt;&gt;();
              for(int i=0; i&lt;productIds.size();i++){
                      CustProduct custProduct = new CustProduct();
                      custProduct.setCustProductId(productIds.get(i));
                      //Here I want set productName and productDetails to custProduct Object(Iterating through ProductList and get from Product)
                      custProducts.add(custProduct);
                  }
              }
              customer.setCustProducts(custProducts);
          }
      
  </code></pre>
  <p>Can anyone please help to fill out the comment section above?
  Or is there any other option to map these objects?</p>
  <p>Edited : I tried the below solution but the interface implementation class itself changed.</p>