AnnotationUtils { public static boolean isInBetween( final Annotation between, final Annotation source, final Annotation target) { int left; int right; if (source.getEnd() <= target.getBegin()) { left = source.getEnd(); right = target.getBegin(); } else { left = target.getEnd(); right = source.getBegin(); } return left <= between.getBegin() && between.getEnd() <= right; } private  AnnotationUtils(); static Optional<T> getSingleCovered(
      final Class<T> clazz, final Annotation annotation); static List<T> filterToTopLevelAnnotations(
      final Collection<T> annotations); static boolean isInBetween(
      final Annotation between, final Annotation source, final Annotation target); static boolean isCovering(final Annotation covering, final Annotation covered);  }
@Test public void testIsInBetween() { final Annotation left = new Annotation(jCas, 0, 3); final Annotation mid = new Annotation(jCas, 5, 6); final Annotation right = new Annotation(jCas, 8, 10); Assert.assertTrue(AnnotationUtils.isInBetween(mid, left, right)); Assert.assertTrue(AnnotationUtils.isInBetween(mid, right, left)); Assert.assertFalse(AnnotationUtils.isInBetween(left, mid, right)); Assert.assertFalse(AnnotationUtils.isInBetween(right, mid, left)); final Annotation mid2 = new Annotation(jCas, 2, 9); Assert.assertFalse(AnnotationUtils.isInBetween(mid2, right, left)); Assert.assertFalse(AnnotationUtils.isInBetween(mid2, left, right)); final Annotation mid3 = new Annotation(jCas, 5, 9); Assert.assertFalse(AnnotationUtils.isInBetween(mid3, right, left)); Assert.assertFalse(AnnotationUtils.isInBetween(mid3, left, right)); }