title: How to use lambda/Stream api to filter distinct elements by object Attribute/Property
body: <p>I have a <code>List</code> of <code>Object</code>. Every object has a map with a key named "xyz". I want elements in the list which has unique value to that particular key. </p>
  
  <p>I know we can do this easily with set/map but I'm particularly looking for lambda solution.</p>
  
  <p>I thought this would work.</p>
  
  <pre><code>list.stream()
      .filter(distinctByXyz(f -&gt; f.getMap.get("xyz")))
      .collect(Collectors.toList()));
  </code></pre>
  
  <p>I've a function to distinct them</p>
  
  <pre><code>private &lt;T&gt; Predicate&lt;T&gt; distinctByKey(Function&lt;? super T, Object&gt; keyExtractor){
      Map&lt;Object, Boolean&gt; map = new ConcurrentHashMap&lt;&gt;();
      return t -&gt; map.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
  }
  </code></pre>
  
  <p>The problem is the function f.getMap() inside filter isnt working. Showing compilation error (Cannot resolve method) </p>