class MatchResultWithOffset implements MatchResult {

    @Override
    public int groupCount() {
        if (groupCount == null) {
            int groupIndex = groupOffset + 1;
            while (groupIndex <= delegate.groupCount() && delegate.end(groupIndex) <= delegate.end(groupOffset)) {
                groupIndex++;
            }
            groupCount = (groupIndex - 1) - groupOffset;
        }
        return groupCount;
    }

    public  MatchResultWithOffset(MatchResult delegate, int groupOffset);

}