@Test public void shouldFulfillEqualityRules() throws Exception { assertEquals(new ImmutablePair<>(null, "foo"), new ImmutablePair<>(null, "foo")); assertFalse(new ImmutablePair<>("foo", 0).equals(new ImmutablePair<>("foo", null))); assertFalse(new ImmutablePair<>("foo", "bar").equals(new ImmutablePair<>("xyz", "bar"))); final ImmutablePair<String, String> p = new ImmutablePair<>("foo", "bar"); assertTrue(p.equals(p)); assertFalse(p.equals(new Object())); }
@Override public boolean equals(Object obj) { if (obj == this) { return true; } else if (!(obj instanceof Entry)) { return false; } else { Entry<?, ?> other = (Entry<?, ?>) obj; return Objects.equals(this.getKey(), other.getKey()) && Objects.equals(this.getValue(), other.getValue()); } }
ImmutablePair implements Entry<L, R>, Serializable, Comparable<ImmutablePair<L, R>> { @Override public boolean equals(Object obj) { if (obj == this) { return true; } else if (!(obj instanceof Entry)) { return false; } else { Entry<?, ?> other = (Entry<?, ?>) obj; return Objects.equals(this.getKey(), other.getKey()) && Objects.equals(this.getValue(), other.getValue()); } } }
ImmutablePair implements Entry<L, R>, Serializable, Comparable<ImmutablePair<L, R>> { @Override public boolean equals(Object obj) { if (obj == this) { return true; } else if (!(obj instanceof Entry)) { return false; } else { Entry<?, ?> other = (Entry<?, ?>) obj; return Objects.equals(this.getKey(), other.getKey()) && Objects.equals(this.getValue(), other.getValue()); } } ImmutablePair(L left, R right); }
ImmutablePair implements Entry<L, R>, Serializable, Comparable<ImmutablePair<L, R>> { @Override public boolean equals(Object obj) { if (obj == this) { return true; } else if (!(obj instanceof Entry)) { return false; } else { Entry<?, ?> other = (Entry<?, ?>) obj; return Objects.equals(this.getKey(), other.getKey()) && Objects.equals(this.getValue(), other.getValue()); } } ImmutablePair(L left, R right); L getLeft(); R getRight(); @Override final L getKey(); @Override R getValue(); @Override R setValue(R value); @Override @SuppressWarnings("unchecked") int compareTo(ImmutablePair<L, R> o); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); }
ImmutablePair implements Entry<L, R>, Serializable, Comparable<ImmutablePair<L, R>> { @Override public boolean equals(Object obj) { if (obj == this) { return true; } else if (!(obj instanceof Entry)) { return false; } else { Entry<?, ?> other = (Entry<?, ?>) obj; return Objects.equals(this.getKey(), other.getKey()) && Objects.equals(this.getValue(), other.getValue()); } } ImmutablePair(L left, R right); L getLeft(); R getRight(); @Override final L getKey(); @Override R getValue(); @Override R setValue(R value); @Override @SuppressWarnings("unchecked") int compareTo(ImmutablePair<L, R> o); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }