WordPosCap implements Comparable<WordPosCap>, Serializable { @Override public int hashCode() { int result = word.hashCode(); result = 31 * result + partOfSpeech.hashCode(); result = 31 * result + Boolean.hashCode(isCapitalized); return result; } WordPosCap(String word, PartOfSpeech partOfSpeech, boolean isCapitalized); String getWord(); PartOfSpeech getPartOfSpeech(); boolean isCapitalized(); PosCap toPosCap(); @Override boolean equals(@Nullable Object o); @Override int hashCode(); @Override int compareTo(WordPosCap o); @Override String toString();  }
@Test public void testHashCodeDifferentWord() { WordPosCap first = new WordPosCap("aWord", PartOfSpeech.NN, false); WordPosCap second = new WordPosCap("word", PartOfSpeech.NN, false); assertFalse(first.hashCode() == second.hashCode()); }
@Test public void testHashCodeDifferentPos() { WordPosCap first = new WordPosCap("aWord", PartOfSpeech.NN, false); WordPosCap second = new WordPosCap("aWord", PartOfSpeech.NNS, false); assertFalse(first.hashCode() == second.hashCode()); }
@Test public void testHashCodeDifferentCapitalization() { WordPosCap first = new WordPosCap("aWord", PartOfSpeech.NN, false); WordPosCap second = new WordPosCap("aWord", PartOfSpeech.NN, true); assertFalse(first.hashCode() == second.hashCode()); }
@Test public void testHashCodeEqual() { WordPosCap first = new WordPosCap("aWord", PartOfSpeech.NN, false); WordPosCap second = new WordPosCap("aWord", PartOfSpeech.NN, false); assertTrue(first.hashCode() == second.hashCode()); }