title: HashMap<String, Object> - How to return an Object having only its argument?
body: <p>Given the following details I need to write a method which returns an Object <code>Person</code>: </p>
  
  <pre><code>public class Person {
  
      private String firstName;
      private String lastName;
      private int deskNo;
      private String departmentName;
      ...
  }
  // this class also contains get methods for each argument
  </code></pre>
  
  <p>Objects <code>Person</code> are stored in a <code>HashMap</code>, where Key is same as <code>lastName</code> for each Object. Value is obviously <code>Person</code> Object.</p>
  
  <pre><code>private final Map&lt;String, Person&gt; employeeHM = new HashMap&lt;&gt;();
  ...
  employeeHM.put("Doe", new Person("Jon", "Doe", 14, "Sales");
  </code></pre>
  
  <p>I approached this problem with several solutions but failed in each instance. Is there a way do directly compare the <code>firstName</code> with <code>lastName</code> and return matching Object? One of my ideas was to use a <code>Set</code> or a <code>Colleciton</code>, but I am fairly sure this is overcomplicating things.</p>
  
  <pre><code>@Override
  public Person findPersonByFirstName(String firstName) {
     // ?
  }
  </code></pre>