AnnotationUtil { public static boolean overlaps(Annotation annotation1, Annotation annotation2) { Annotation firstAnnotation, secondAnnotation; if (annotation1.getBegin() == annotation2.getBegin()) return true; if (annotation1.getBegin() < annotation2.getBegin()) { firstAnnotation = annotation1; secondAnnotation = annotation2; } else { firstAnnotation = annotation2; secondAnnotation = annotation1; } if (firstAnnotation.getEnd() > secondAnnotation.getBegin()) return true; return false; }  static T selectFirstMatching(
      JCas jCas,
      Class<T> selectedType,
      Annotation annotation); static List<T> selectMatching(
      JCas jCas,
      Class<T> selectedType,
      Annotation annotation); static boolean contains(Annotation bigAnnotation, Annotation smallAnnotation); static boolean overlaps(Annotation annotation1, Annotation annotation2); static int size(Annotation annotation); static String getSurroundingText(
      JCas jCas,
      Annotation annotation,
      Class<TOKEN_TYPE> tokenClass,
      int numberOfTokens,
      boolean before); static void sort(List<T> annotations); static int[] getAnnotationsExtent(List<? extends Annotation> annotations);  }
@Test public void testOverlaps() { Token token1 = new Token(jCas, 0, 0); Token token2 = new Token(jCas, 0, 0); assertTrue(AnnotationUtil.overlaps(token1, token2)); assertTrue(AnnotationUtil.overlaps(token2, token1)); token1 = new Token(jCas, 0, 0); token2 = new Token(jCas, 0, 1); assertTrue(AnnotationUtil.overlaps(token1, token2)); assertTrue(AnnotationUtil.overlaps(token2, token1)); token1 = new Token(jCas, 0, 5); token2 = new Token(jCas, 5, 10); assertFalse(AnnotationUtil.overlaps(token1, token2)); assertFalse(AnnotationUtil.overlaps(token2, token1)); token1 = new Token(jCas, 0, 5); token2 = new Token(jCas, 4, 10); assertTrue(AnnotationUtil.overlaps(token1, token2)); assertTrue(AnnotationUtil.overlaps(token2, token1)); token1 = new Token(jCas, 0, 5); token2 = new Token(jCas, 6, 10); assertFalse(AnnotationUtil.overlaps(token1, token2)); assertFalse(AnnotationUtil.overlaps(token2, token1)); token1 = new Token(jCas, 0, 5); token2 = new Token(jCas, 1, 10); assertTrue(AnnotationUtil.overlaps(token1, token2)); assertTrue(AnnotationUtil.overlaps(token2, token1)); }