RevisionKey implements Serializable { @Override @SuppressWarnings("unchecked") public boolean equals(Object obj) { if (!(obj instanceof RevisionKey)) { return false; } RevisionKey<ID> other = (RevisionKey<ID>) obj; return Objects.equals(this.id, other.id) && Objects.equals(this.revision, other.revision); } RevisionKey(ID id, int revision); int getRevision(); void setRevision(int revision); ID getId(); void setId(ID id); @Override int hashCode(); @Override @SuppressWarnings("unchecked") boolean equals(Object obj);  }
@Test public void testEquals() { RevisionKey<Integer> key1 = new RevisionKey<>(1, 1); assertTrue(key1.equals(key1)); assertFalse(key1.equals(null)); assertFalse(key1.equals(new Object())); RevisionKey<Integer> key2 = new RevisionKey<>(1, 2); assertFalse(key1.equals(key2)); RevisionKey<Integer> key3 = new RevisionKey<>(2, 1); assertFalse(key1.equals(key3)); }