title: check if a list already contains an object with similar values - java
body: <p>I need to add an object to a list only when the given list does not already contain a object with similar properties</p>
  
  <pre><code>List&lt;Identifier&gt; listObject; //list
  Identifier i = new Identifier(); //New object to be added
  i.type = "TypeA";
  i.id = "A";
  if(!listObject.contains(i)) {   // check
      listObject.add(i);  
  }
  </code></pre>
  
  <p>I tried <code>contains()</code> to have a check on the existing list. If the list already has an object say <code>j</code> with <code>j.type = "TypeA"</code> and <code>j.id = "A"</code>, I don't want to add that to list.</p>
  
  <p>Can you please help me achieve this by overriding equals or any solution that can do?</p>