WordPos implements Comparable<WordPos>, Serializable { @Override public int compareTo(WordPos o) { int result = word.compareTo(o.word); if (result == 0) { result = tag.compareTo(o.tag); } 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 testCompareToDifferentWord() { WordPos first = new WordPos("first", PartOfSpeech.NN); WordPos second = new WordPos("second", PartOfSpeech.NN); assertEquals(first.compareTo(second), "first".compareTo("second")); }
@Test public void testCompareToDifferentTag() { WordPos first = new WordPos("aWord", PartOfSpeech.NN); WordPos second = new WordPos("aWord", PartOfSpeech.NNS); assertEquals(first.compareTo(second), PartOfSpeech.NN.compareTo(PartOfSpeech.NNS)); }
@Test public void testCompareToEqual() { WordPos first = new WordPos("aWord", PartOfSpeech.NNS); WordPos second = new WordPos("aWord", PartOfSpeech.NNS); assertEquals(first.compareTo(second), 0); }