title: Orika mapping nested sublist
body: <p>Consider the below example.</p>
  
  <p>Group.java(GroupDTO.java also has the same properties)</p>
  
  <pre><code>import java.util.List;
  
  public class Group {
      public Group(List&lt;Person&gt; persons) {
          this.persons = persons;
      }
  
      private List&lt;Person&gt; persons;
  
      public List&lt;Person&gt; getPersons() {
          return persons;
      }
  
      public void setPersons(List&lt;Person&gt; persons) {
          this.persons = persons;
      }
  }
  </code></pre>
  
  <p>Person.java(PersonDTO.java also has the same properties)</p>
  
  <pre><code>import java.util.List;
  
  public class Person {
  
      public Person(){}
      public Person(List&lt;Name&gt; names, Integer age) {
          this.names = names;
          this.age = age;
      }
  
      private List&lt;Name&gt; names;
      private Integer age;
  
      public Integer getAge() {
          return age;
      }
  
      public void setAge(Integer age) {
          this.age = age;
      }
  
      public List&lt;Name&gt; getNames() {
          return names;
      }
  
      public void setNames(List&lt;Name&gt; names) {
          this.names = names;
      }
  }
  </code></pre>
  
  <p>Name.java(NameDTO.java also has the same properties)</p>
  
  <pre><code>public class Name {
      public Name(String first, String last) {
          this.first = first;
          this.last = last;
      }
  
      private String first;
      private String last;
  
      public String getFirst() {
          return first;
      }
  
      public void setFirst(String first) {
          this.first = first;
      }
  
      public String getLast() {
          return last;
      }
  
      public void setLast(String last) {
          this.last = last;
      }
  }
  </code></pre>
  
  <p>And when I run the below class I get the following exception.</p>
  
  <pre><code>import ma.glasnost.orika.MapperFacade;
  import ma.glasnost.orika.MapperFactory;
  import ma.glasnost.orika.impl.DefaultMapperFactory;
  import ma.glasnost.orika.metadata.ClassMapBuilder;
  
  import java.util.LinkedList;
  import java.util.List;
  
  public class Mapper {
  
      public static void main(String[] args) {
  
          List&lt;Name&gt; names = new LinkedList&lt;Name&gt;();
          names.add(new Name("foo", "bar"));
          names.add(new Name("lorem", "ipsum"));
          List&lt;Person&gt; persons = new LinkedList&lt;Person&gt;();
          persons.add(new Person(names, 30));
          persons.add(new Person(names, 40));
          Group g1 = new Group(persons);
  
          MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
          ClassMapBuilder classMapBuilder = mapperFactory.classMap(Group.class, GroupDTO.class);
          classMapBuilder.field("persons{age}", "persons{age}");
          classMapBuilder.field("persons{names{first}}", "persons{names{first}}");
          classMapBuilder.field("persons{names{last}}", "persons{names{last}}");
          classMapBuilder.byDefault().register();
  
          MapperFacade mapper = mapperFactory.getMapperFacade();
          GroupDTO groupDTO = mapper.map(g1, GroupDTO.class);
  
          for(Person p:groupDTO.getPersons()){
              System.out.println(p.getAge());
              for(Name n:p.getNames()){
                  System.out.println(n.getFirst());
                  System.out.println(n.getFirst());
              }
          }
  
      }
  }
  </code></pre>
  
  <p>Exception</p>
  
  <pre><code>Exception in thread "main" ma.glasnost.orika.MappingException: java.lang.NullPointerException
      at ma.glasnost.orika.impl.generator.MapperGenerator.build(MapperGenerator.java:104)
      at ma.glasnost.orika.impl.DefaultMapperFactory.buildMapper(DefaultMapperFactory.java:1480)
      at ma.glasnost.orika.impl.DefaultMapperFactory.build(DefaultMapperFactory.java:1295)
      at ma.glasnost.orika.impl.DefaultMapperFactory.getMapperFacade(DefaultMapperFactory.java:883)
      at Mapper.main(Mapper.java:28)
  Caused by: java.lang.NullPointerException
      at ma.glasnost.orika.impl.generator.specification.MultiOccurrenceToMultiOccurrence.registerClassMaps(MultiOccurrenceToMultiOccurrence.java:397)
      at ma.glasnost.orika.impl.generator.specification.MultiOccurrenceToMultiOccurrence.generateMappingCode(MultiOccurrenceToMultiOccurrence.java:72)
      at ma.glasnost.orika.impl.generator.SourceCodeContext.mapAggregateFields(SourceCodeContext.java:721)
      at ma.glasnost.orika.impl.generator.MapperGenerator.addMapMethod(MapperGenerator.java:182)
      at ma.glasnost.orika.impl.generator.MapperGenerator.build(MapperGenerator.java:70)
      ... 4 more
  </code></pre>
  
  <p>Sorry about the long post. Am trying map fields from inside List&lt;> which is again inside another List&lt;>. What would be the best approach or am I doing something wrong here?</p>