title: Efficient algorithm for merging objects in ArrayList
body: <p>I have an ArrayList of custom objects (DTO) , the structure of DTO:</p>
  
  <pre><code>private String id;
  private String text;
  private String query;
  private String locatorId;
  private Collection&lt;String&gt; categories;
  private Collection&lt;String&gt; triggers;
  </code></pre>
  
  <p>I have two task:</p>
  
  <ul>
  <li>Remove duplicates in Array (it seems OK, I should use HashSet)</li>
  <li>Find objects in ArrayList with the same id field and merge them into one object (I should merge fields categories and triggers) and create final List with merged objects.</li>
  </ul>
  
  <p>What is the most efficient approach for such task? Also I'm interesting to use <strong>Lambda</strong> expression in my algorithm.</p>