title: handle duplicate key in Collectors.toMap() function
body: <p>I am creating a map which its (key,value) will be (name, address) in my Person object: </p>
  
  <pre><code>Map&lt;String, String&gt; myMap = persons.stream.collect(Collector.toMap(person.getName(), person.getAddress(), (address1, address2) -&gt; address1));
  </code></pre>
  
  <p>In the duplicate key situation, I would like to skip to add the second address to the map and would like to log the name also. Skipping the duplicate address I can do already using mergeFunction, but in oder to log the name I need in this mergeFunction the person object, something like: </p>
  
  <pre><code>(address1, address2) -&gt; {
                             System.out.println("duplicate "+person.name() + " is found!");
                             return address1;
                          }
  </code></pre>
  
  <p>I am getting stuck by passing person object to this merge function.</p>