boolean (Object obj) { if (obj == this) return true; if (!(obj instanceof DistinctPair that)) return false; if (that.myOrdered != this.myOrdered) return false; return that.getFirst().equals(this.getFirst()) && that.getSecond().equals(this.getSecond()) || (!myOrdered && that.getSecond().equals(this.getFirst()) && that.getFirst().equals(this.getSecond())); }