title: LEFT OUTER JOIN of two collections
body: <p>The question is pretty much in the title. I'm looking for an algorithm more efficient than full search through the collections.</p>
  
  <p>I have two collections:</p>
  
  <pre><code>List&lt;Map&lt;TypeId, Object&gt; &gt; col1;
  List&lt;Entity&gt; col2;
  </code></pre>
  
  <p>Where </p>
  
  <pre><code>public enum TypeId{
      PLAYER,
      PARTNER,
      PLATFORM,
      AMOUNT
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public class Entity{
      private int player_id;
      private int platform_id
      private BigDecimal amount;
  
      //GET, SET
  }
  </code></pre>
  
  <p>The <code>col1</code> collection which is of the type <code>List&lt;Map&lt;TypeId, Object&gt; &gt;</code> contains only <code>PLAYER, PARTNER,  PLATFORM</code> <code>TypeId</code>s. </p>
  
  <p>I need to write a method:</p>
  
  <pre><code>public List&lt;Map&lt;TypeId, Object&gt; &gt; merge(List&lt;Map&lt;TypeId, Object&gt; &gt; col1, List&lt;Entity&gt; col2){
      //Impl
  }
  </code></pre>
  
  <p>Which is going to produce <code>List&lt;Map&lt;TypeId, Object&gt; &gt;</code> each the entry <code>entry</code> of the map contains additional key-value <code>(AMOUNT, AMOUNT's value)</code>  where <code>AMOUNT's value</code> is the value of the <code>amount</code> field of the instance <code>e</code> of <code>Entity</code> if <code>e.player_id = entry.get(PLAYER) &amp;&amp; e.platform_id = entry.get(PLATFORM)</code> and <code>null</code> otherwise.</p>
  
  <p>In fact, the operation would be the same as</p>
  
  <pre><code>col1 LEFT OUTER JOIN 
  col2 ON e.player_id = entry.get(PLAYER) &amp;&amp; e.platform_id = entry.get(PLATFORM)
  </code></pre>
  
  <p>SAMPLE:</p>
  
  <pre><code>col1:
  [{PLATFORM: 1, PARTNER: 1, PLAYER: 1},
   {PLATFORM: 1, PARTNER: 3, PLAYER: 1},
   {PLATFORM: 2, PARTNER: 1, PLAYER: 2}
   {PLATFORM: 3, PARTNER: 4, PLAYER: 5}]
  
  col2:
  [Entity(platform_id = 1, player_id = 1, amount = 100),
  Entity(platform_id = 2, player_id = 2, amount = 200),
  Entity(platform_id = 3, player_id = 4, amount = 300)]
  
  result:
  [{PLATFORM: 1, PARTNER: 1, PLAYER: 1, AMOUNT: 100},
   {PLATFORM: 1, PARTNER: 3, PLAYER: 1, AMOUNT: 100},
   {PLATFORM: 2, PARTNER: 1, PLAYER: 2, AMOUNT: 200},
   {PLATFORM: 3, PARTNER: 4, PLAYER: 5, AMOUNT: null}]
  </code></pre>