WordPosCap implements Comparable<WordPosCap>, Serializable { @Override public int compareTo(WordPosCap o) { int result = word.compareTo(o.word); if (result == 0) { result = partOfSpeech.compareTo(o.partOfSpeech); } if (result == 0) { result = Boolean.compare(isCapitalized, o.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 testCompareToDifferentWord() { WordPosCap first = new WordPosCap("aWord", PartOfSpeech.NN, false); WordPosCap second = new WordPosCap("word", PartOfSpeech.NN, false); assertEquals(first.compareTo(second), "aWord".compareTo("word")); }
@Test public void testCompareToDifferentPos() { WordPosCap first = new WordPosCap("word", PartOfSpeech.NN, false); WordPosCap second = new WordPosCap("word", PartOfSpeech.NNS, false); assertEquals(first.compareTo(second), PartOfSpeech.NN.compareTo(PartOfSpeech.NNS)); }
@Test public void testCompareToDifferentCapitalization() { WordPosCap first = new WordPosCap("word", PartOfSpeech.NN, false); WordPosCap second = new WordPosCap("word", PartOfSpeech.NN, true); assertEquals(first.compareTo(second), Boolean.compare(false, true)); }
@Test public void testCompareTo() { WordPosCap first = new WordPosCap("word", PartOfSpeech.NN, false); WordPosCap second = new WordPosCap("word", PartOfSpeech.NN, false); assertEquals(first.compareTo(second), 0); }