WordPos implements Comparable<WordPos>, Serializable { @Override public int hashCode() { int result = word.hashCode(); result = 31 * result + tag.hashCode(); return result; } WordPos();  WordPos(String word, PartOfSpeech tag); WordPos forward(); String getWord(); void setWord(String word); PartOfSpeech getTag(); void setTag(PartOfSpeech tag); @Override boolean equals(@Nullable Object o); @Override int hashCode(); @Override int compareTo(WordPos o); @Override String toString();  }
@Test public void testHashCodeEqual() { WordPos first = new WordPos("aWord", PartOfSpeech.NN); WordPos second = new WordPos("aWord", PartOfSpeech.NN); assertTrue(first.hashCode() == second.hashCode()); }
@Test public void testHashCodeNotEqual() { WordPos first = new WordPos("aWord", PartOfSpeech.NN); WordPos second = new WordPos("aWord", PartOfSpeech.NNS); WordPos third = new WordPos("Word", PartOfSpeech.NNS); assertFalse(first.hashCode() == second.hashCode()); assertFalse(second.hashCode() == third.hashCode()); }