title: Can I override Hashsets way of determine duplicate?
body: <p>Im using Hashset that stores JSONObjects.
  I know hashset uses both hashCode() and equals method to determine if the object is duplicate.</p>
  
  <p>After checking i can see that the same JSONObject returns 2 different hascodes even tho equals() and similar() returns true, which basically means JSONObject didnt override the hashcode() properly. </p>
  
  <p>I am aware that if ill use libs like Gson or Jackson i would probably solve this issue, but my code is deeply invested in using JSONObject and refactor all of it to use one of those libs will take 2 much time.</p>
  
  <p>My question - is there a way to set an hashSet way of deciding duplicates?</p>
  
  <p>something like </p>
  
  <pre><code>HashSet&lt;JSONObject&gt; hs = new HashSet();
  hs.setDuplicateStrategy((o1, o2) =&gt; { o1.similar(o2)});
  </code></pre>
  
  <p>any other solutions will be welcome</p>