FindResult (int offset) { FindResult afterCaret = null; for (FindResult occurrence : getOccurrences()) { if (offset <= occurrence.getStartOffset() && (afterCaret == null || occurrence.getStartOffset() < afterCaret.getStartOffset())) { afterCaret = occurrence; } } return afterCaret; }