title: Most efficient way to see if an ArrayList contains an object in Java
body: <p>I have an ArrayList of objects in Java.  The objects have four fields, two of which I'd use to consider the object equal to another.  I'm looking for the most efficient way, given those two fields, to see if the array contains that object.</p>
  
  <p>The wrench is that these classes are generated based on XSD objects, so I can't modify the classes themselves to overwrite the <code>.equals</code>.  </p>
  
  <p>Is there any better way than just looping through and manually comparing the two fields for each object and then breaking when found?  That just seems so messy, looking for a better way.</p>
  
  <p><strong>Edit:</strong> the ArrayList comes from a SOAP response that is unmarshalled into objects.</p>