GisFeatureId { @Override public int hashCode() { return new HashCodeBuilder() .append(geonamesId) .toHashCode(); } GisFeatureId(Long geonamesId); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); Long getGeonamesId();  }
@Test public void twoGisFeaturesIdsWithSameGeonamesIdShouldBeEqual() { GisFeatureId feature1 = new GisFeatureId(1L); GisFeatureId feature2 = new GisFeatureId(1L); Assert.assertEquals(feature1, feature2); Assert.assertEquals(feature1.hashCode(), feature2.hashCode()); }
@Test public void twoGisFeaturesIdsWithDifferentGeonamesIdShouldNotBeEqual() { GisFeatureId feature1 = new GisFeatureId(1L); GisFeatureId feature2 = new GisFeatureId(2L); Assert.assertThat(feature1, not(equalTo(feature2))); Assert.assertThat(feature1.hashCode(), not(equalTo(feature2.hashCode()))); }