title: Using Jackson XML binding to map lists to Pojo
body: <p>I am using Jackson's XML binding to convert XML into a Java List, via an initial mapping to a Java POJO.  What I have written works but I don't think I am using Jackson correctly.</p>
  
  <p>I am stuck with this ugly XML:</p>
  
  <pre><code>&lt;groups&gt;
    &lt;groups&gt;One&lt;/groups&gt;
    &lt;groups&gt;Two&lt;/groups&gt;
    &lt;groups&gt;Three&lt;/groups&gt;
  &lt;/groups&gt;
  </code></pre>
  
  <p>Here is the Java POJO I am using.  Note the <code>setGroups(String)</code> method is actually adding to the list.</p>
  
  <pre><code>public class Groups {
     private List&lt;String&gt; groups = new ArrayList&lt;String&gt;();
  
     public void setGroups(String group) {
        groups.add(group);
     }
  
     public List&lt;String&gt; getGroups() { 
        return this.groups;
     }
  }
  </code></pre>
  
  <p>Here is how I invoke Jackson's XmlMapper.</p>
  
  <pre><code>public List&lt;String&gt; getListOfGroups(String xmlDoc) {
     XmlMapper mapper = new XmlMapper();
     Groups groups = mapper.readValue(xmlDoc, Groups.class);
     return groups.getGroups();
  }
  </code></pre>
  
  <p>This is actually working as I need it to work. I get a Groups class with a list populated with the elements I expect.  I am wondering, is approach is correct? I don't like that I have a setter doing an add but everything I've tried has not worked.</p>