title: How do I add to a set based on a specific predicate in Java?
body: <p>I have a set in Java containing people:</p>
  
  <pre><code>Set&lt;Person&gt; uniquePeople = new HashSet&lt;Person&gt;();
  </code></pre>
  
  <p>I also have a list of a ton of people (of whom some possess the same name, eg. there is more than one "Bob" in the world).</p>
  
  <pre><code>List&lt;Person&gt; theWorld = // ... a BIG list of people
  </code></pre>
  
  <p>I want to iterate through this list and add a person to the <code>uniquePeople</code> set if and only if their name doesn't exist in the set, eg:</p>
  
  <pre><code>for (Person person : theWorld) {
      uniquePeople.add(person IFF uniquePeople.doesNotContain(person.name));
  }
  </code></pre>
  
  <p>Is there an easy way to do this in Java? Also, Guava might do this (?) but I haven't used it at all so I would appreciate a point in the right direction.</p>