title: Selma map List<T> to T
body: <p>I am using Selma and I have the following class:</p>
  
  <pre><code>public class Customer
  {
      private int id;
      private String email;
      private String firstName;
      private String lastName;
      private Date registeredDate;
      private List&lt;Address&gt; addresses;
  
  }
  </code></pre>
  
  <p>I want to map it to: </p>
  
  <pre><code>public class Customer
  {
      private String id;
      private String email;
      private String firstName;
      private String lastName;
      private Date registeredDate;
      private String company;
      private Address address1;
      private Address address2;
  }
  </code></pre>
  
  <p>Is there any way to cast the (int) <code>id</code> to (String) <code>id</code> and to set the first address from the <code>List</code> to <code>address1</code> and the second address to <code>address2</code>?</p>
  
  <p>I was thinking of using an interceptor, but this way I will have to manually map the <code>Address</code> classes. Is there a way to use Selma to automatically map the address classes in the interceptor? For example:</p>
  
  <pre><code> public class CustomerCustomMapper
  {
      public void interceptMyCustomerToCustomer(com.mycode.domain.Customer source, Customer destination) {
  
          if(source.getAddresses() != null &amp;&amp; source.getAddresses().size() &gt; 0)
          {
              com.mycode.domain.Address myAddress1 = source.getAddresses().get(0);
  
              AddressMapper addressMapper = Selma.builder(AddressMapper.class).build();
  
              Address address1 = addressMapper.mapAddress(myAddress1);
              destination.setAddress1(address1);
  
             // do the same for address2
          }
      }
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>Regarding mapping the Address class I did it the way I showed above. I created an <code>AddressMapper</code> with the following code inside: <code>Address toAddress(com.mycode.domain.Address address);</code></p>
  
  <p>Then I created an addressMapper and used it to map the Address autimatically:</p>
  
  <pre><code>AddressMapper addressMapper = Selma.builder(AddressMapper.class).build();
  </code></pre>
  
  <p>As for the id, currently I have to create an interceptor for every class that I map (almost every class has an Id in it (SQL)), and manually set the id like so: <code>destination.setId(Integer.toString(source.getId()));</code></p>
  
  <p>It is quite frustrating actually, but sadly I can't find a better option.</p>