WordDistance implements Comparable<WordDistance> { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } WordDistance other = (WordDistance) obj; if (distance != other.distance) { return false; } if (word == null) { if (other.word != null) { return false; } } else if (!word.equals(other.word)) { return false; } if (previous == null) { if (other.previous != null) { return false; } } else if (!previous.equals(other.previous)) { return false; } return true; } WordDistance(WordToken word);  WordDistance(WordToken word, WordDistance wordDistance); WordToken getWord(); int getDistance(); WordDistance getWordDistance(); List<WordToken> getWords(); @Override int compareTo(WordDistance o); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testEquals() throws UIMAException { final JCas jCas = JCasSingleton.getJCasInstance(); final WordToken w1 = new WordToken(jCas); final WordToken w2 = new WordToken(jCas); final WordDistance a = new WordDistance(w1); final WordDistance b = new WordDistance(w2); final WordDistance c = new WordDistance(w2, a); final WordDistance nwd1 = new WordDistance(null); final WordDistance nwd2 = new WordDistance(null); assertNotEquals(a, null); assertEquals(a, a); assertNotEquals(a, "Hello"); assertNotEquals(a, b); assertNotEquals(a, c); assertNotEquals(c, b); assertEquals(nwd1, nwd2); assertNotEquals(a.hashCode(), b.hashCode()); assertNotEquals(a.hashCode(), nwd1.hashCode()); assertEquals(-1, a.compareTo(c)); }