MessageVersion implements Comparable<MessageVersion> { @Override public int hashCode() { return Arrays.hashCode(getVersionParts()); } MessageVersion(String version); @Override int compareTo(MessageVersion that); @Override boolean equals(Object that); @Override int hashCode(); @Override String toString(); static final MessageVersion NO_VERSION; }
@Test public void testHashCode() throws Exception { MessageVersion version1 = new MessageVersion("1.0.0"); MessageVersion version2 = new MessageVersion("1.0.0"); MessageVersion version3 = new MessageVersion("1"); assertEquals(version1.hashCode(), version2.hashCode()); assertEquals(version1.hashCode(), version3.hashCode()); }