title: Most compact way to compare three objects for equality using Java?
body: <p>What's the most compact code to compare three objects for (semantic) equality using Java? I have a business rule that the objects must be unique i.e. A <em>is different to B, A is different to C and B is different to C.</em></p>
  
  <p>Assume that the objects are all of the same class and have correctly overridden <code>equals</code> and <code>hashCode</code> methods. A slight wrinkle is that object <em>C</em> could be <code>null</code>&mdash;if this is the case then <em>A</em> and <em>B</em> have to be different to each other.</p>
  
  <p>I have some code but it's a bit workmanlike for my tastes.</p>