title: Java 8 Distinct by property
body: <p>In Java 8 how can I filter a collection using the <code>Stream</code> API by checking the distinctness of a property of each object?</p>
  
  <p>For example I have a list of <code>Person</code> object and I want to remove people with the same name,</p>
  
  <pre><code>persons.stream().distinct();
  </code></pre>
  
  <p>Will use the default equality check for a <code>Person</code> object, so I need something like,</p>
  
  <pre><code>persons.stream().distinct(p -&gt; p.getName());
  </code></pre>
  
  <p>Unfortunately the <code>distinct()</code> method has no such overload. Without modifying the equality check inside the <code>Person</code> class is it possible to do this succinctly?</p>