title: Generic XML accumulator Java 8
body: <p>I have to process a lot of information of a certain type. So an xml accumulator might fit well into my use case. So whenever I encounter xml such as:</p>
  
  <pre><code>&lt;Currency1&gt;
      //... 
  &lt;/Currency1&gt;
  </code></pre>
  
  <p>I would add it to some sort of container or <code>list</code> or whatever. So after processing, the accumulator should contain something like this:</p>
  
  <pre><code>&lt;Currencies&gt;
      &lt;Currency1&gt;
          // et cetera
      &lt;/Currency1&gt;
      &lt;Currency2&gt;
          // et cetera
      &lt;/Currency2&gt;
      &lt;Currency3&gt;
          // et cetera
      &lt;/Currency3&gt;
  &lt;/Currencies&gt;
  </code></pre>
  
  <p>How can I accomplish this with Java 8? I don't want to just use the native java Collections framework</p>
  
  <p>Edit: The code is a bit complicated so I reduced it down to this</p>
  
  <pre><code>List&lt;String&gt; l = new ArrayList&lt;&gt;();
  if (formsContext != this.NULL)
  {
      if(dataTemplate.hasCurrencyPayload())
      {
          l.add(dataTemplate.getCurrencyPayload().toString())
      }
      this.processForms(dataTemplate, plForm, formsContext, fModel);
  }
  </code></pre>
  
  <p>The place of interest is the final <code>if</code> condition where I I check to see if the dataTemplate contains a currency payload, if it does I just add it to a String list. Not very robust :(</p>