Pair { @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof Pair)) { return false; } else { Pair<?, ?> oP = (Pair<?, ?>) o; return (key == null ? oP.key == null : key.equals(oP.key)) && (value == null ? oP.value == null : value.equals(oP.value)); } } Pair(K k, V v);  Pair(Pair<? extends K, ? extends V> entry); K getKey(); V getValue(); K getFirst(); V getSecond(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static Pair<K, V> create(K k, V v);  }
@Test public void testEquals() { Pair<Integer, Double> p1 = new Pair<Integer, Double>(null, null); Assert.assertFalse(p1.equals(null)); Pair<Integer, Double> p2 = new Pair<Integer, Double>(null, null); Assert.assertTrue(p1.equals(p2)); p1 = new Pair<Integer, Double>(new Integer(1), new Double(2)); Assert.assertFalse(p1.equals(p2)); p2 = new Pair<Integer, Double>(new Integer(1), new Double(2)); Assert.assertTrue(p1.equals(p2)); Pair<Integer, Float> p3 = new Pair<Integer, Float>(new Integer(1), new Float(2)); Assert.assertFalse(p1.equals(p3)); }