@Test public void testCompareTo() { List<EntityAnnotation> list = Lists.newArrayList(annot1, annot2, annot3, annot4, annot5); Collections.sort(list); List<EntityAnnotation> expected = newArrayList(annot5, annot2, annot1, annot3, annot4); assertThat(list, is(expected)); }
@Override public int compareTo(EntityAnnotation o) { if (range.equals(o.range)) return 0; else if (getEnd() > o.getEnd()) return 1; else if (getEnd() < o.getEnd()) return -1; else if (getStart() < o.getStart()) return 1; else return -1; }
EntityAnnotation extends Token<Entity> implements Comparable<EntityAnnotation> { @Override public int compareTo(EntityAnnotation o) { if (range.equals(o.range)) return 0; else if (getEnd() > o.getEnd()) return 1; else if (getEnd() < o.getEnd()) return -1; else if (getStart() < o.getStart()) return 1; else return -1; } }
EntityAnnotation extends Token<Entity> implements Comparable<EntityAnnotation> { @Override public int compareTo(EntityAnnotation o) { if (range.equals(o.range)) return 0; else if (getEnd() > o.getEnd()) return 1; else if (getEnd() < o.getEnd()) return -1; else if (getStart() < o.getStart()) return 1; else return -1; } protected  EntityAnnotation();  EntityAnnotation(Entity entity, int start, int end); }
EntityAnnotation extends Token<Entity> implements Comparable<EntityAnnotation> { @Override public int compareTo(EntityAnnotation o) { if (range.equals(o.range)) return 0; else if (getEnd() > o.getEnd()) return 1; else if (getEnd() < o.getEnd()) return -1; else if (getStart() < o.getStart()) return 1; else return -1; } protected  EntityAnnotation();  EntityAnnotation(Entity entity, int start, int end); int length(); boolean intersects(EntityAnnotation annotation); @Override int compareTo(EntityAnnotation o); }
EntityAnnotation extends Token<Entity> implements Comparable<EntityAnnotation> { @Override public int compareTo(EntityAnnotation o) { if (range.equals(o.range)) return 0; else if (getEnd() > o.getEnd()) return 1; else if (getEnd() < o.getEnd()) return -1; else if (getStart() < o.getStart()) return 1; else return -1; } protected  EntityAnnotation();  EntityAnnotation(Entity entity, int start, int end); int length(); boolean intersects(EntityAnnotation annotation); @Override int compareTo(EntityAnnotation o);  }