@Override
    public Collection<String> getGroupNames(int startIndex, int numResults)
    {
        final List<String> result = new ArrayList<>();
        int totalCount = 0;

        for ( final GroupProvider provider : getGroupProviders() )
        {
            final int providerStartIndex = Math.max( ( startIndex - totalCount ), 0 );
            totalCount += provider.getGroupCount();
            if ( startIndex >= totalCount )
            {
                continue;
            }
            final int providerResultMax = numResults - result.size();
            result.addAll( provider.getGroupNames( providerStartIndex, providerResultMax ) );
            if ( result.size() >= numResults )
            {
                break;
            }
        }
        return result;
    }
Returns the Collection of all groups provided by each of the providers, ordered by provider-order.

@param startIndex start index in results.
@param numResults number of results to return.
@return the Collection of all group names given the {@code startIndex} and {@code numResults}.
xmppserver/src/main/java/org/jivesoftware/openfire/group/GroupMultiProvider.java