UUIDTimeoutId implements TimeoutId, Serializable { @Override public int hashCode() { return id.hashCode(); } UUIDTimeoutId(final UUID id); static UUIDTimeoutId generateNewId(); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString();  }
@Test public void hashCode_twoDifferentInstancesSameId_haveSameHashCode() { UUID uuid = UUID.randomUUID(); UUIDTimeoutId instance1 = new UUIDTimeoutId(uuid); UUIDTimeoutId instance2 = new UUIDTimeoutId(uuid); int hc1 = instance1.hashCode(); int hc2 = instance2.hashCode(); assertThat("Expected both hash codes to be equal", hc1, equalTo(hc2)); }