@Test public void testEqualsWithDifferentTypes() { final IntPair<String> p = new IntPair<String>(1, "first"); assertFalse(p.equals(1)); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final IntPair<?> other = (IntPair<?>) obj; if (this.first != other.first) return false; return !(this.second != other.second && (this.second == null || !this.second.equals(other.second))); }
IntPair { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final IntPair<?> other = (IntPair<?>) obj; if (this.first != other.first) return false; return !(this.second != other.second && (this.second == null || !this.second.equals(other.second))); } }
IntPair { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final IntPair<?> other = (IntPair<?>) obj; if (this.first != other.first) return false; return !(this.second != other.second && (this.second == null || !this.second.equals(other.second))); } IntPair(int first, T second); }
IntPair { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final IntPair<?> other = (IntPair<?>) obj; if (this.first != other.first) return false; return !(this.second != other.second && (this.second == null || !this.second.equals(other.second))); } IntPair(int first, T second); int getFirst(); T getSecond(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); }
IntPair { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final IntPair<?> other = (IntPair<?>) obj; if (this.first != other.first) return false; return !(this.second != other.second && (this.second == null || !this.second.equals(other.second))); } IntPair(int first, T second); int getFirst(); T getSecond(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }