title: Find Duplicate Objects in an java arraylist
body: <p>First of all, I would like to say that I have searched for an answer to this, but did not get an suitable solution. So I have decided to post it here.</p>
  
  <p>I have an ArrayList of Objects (ArrayList(Provider)). The Provider Object has First Name, Last Name, NPI Number, List (I have not listed all the fields). </p>
  
  <pre><code>Provider {
  
          private long providerId;
          private String npiNumber;
          private PersonName providerName;
          private List&lt;Address&gt; providerAddresses;
  
          }
  </code></pre>
  
  <p>Now I want to find if the ArrayList has duplicates based on these attributes (First Name, Last Name, NPI, Addresses). Each Provider will have 2 addresses. The issue we have is the Provider Object is generated from XSD and cannot be modified. So I cannot override the equals and hashcode methods. So The Hashset(list) does not work.</p>
  
  <p>So what is the best way to check if the ArrayList has duplicate objects. Please let me know</p>
  
  <p>Thanks</p>
  
  <p>Harish</p>