@@ -0,0 +1,2522 @@
+/*%0A * Copyright 2016 - 2018 Acosix GmbH%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage de.acosix.alfresco.utility.repo.batch;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Collection;%0Aimport java.util.Iterator;%0Aimport java.util.List;%0A%0Aimport org.alfresco.repo.batch.BatchProcessWorkProvider;%0Aimport org.alfresco.util.ParameterCheck;%0A%0A/**%0A * Implementation of a simple batch process work provider used to handle pre-collection collections of data entries%0A *%0A * @author Axel Faust%0A */%0Apublic class CollectionWrappingWorkProvider%3CT%3E implements BatchProcessWorkProvider%3CT%3E%0A%7B%0A%0A    protected final List%3CT%3E sourceList;%0A%0A    protected final Iterator%3CT%3E sourceIterator;%0A%0A    protected final int batchSize;%0A%0A    /**%0A     * Creates a new instance of this work provider implementation%0A     *%0A     * @param sourceCollection%0A     *            the source collection to wrap%0A     * @param batchSize%0A     *            the expected batch size to properly size %7B@link BatchProcessWorkProvider#getNextWork() the next work%7D%0A     */%0A    public CollectionWrappingWorkProvider(final Collection%3CT%3E sourceCollection, final int batchSize)%0A    %7B%0A        ParameterCheck.mandatoryCollection(%22sourceCollection%22, sourceCollection);%0A        if (batchSize %3C= 0)%0A        %7B%0A            throw new IllegalArgumentException(%22Batch size must be a positive integer%22);%0A        %7D%0A        this.sourceList = new ArrayList%3C%3E(sourceCollection);%0A        this.batchSize = batchSize;%0A        this.sourceIterator = this.sourceList.iterator();%0A    %7D%0A%0A    /**%0A     * %7B@inheritDoc%7D%0A     */%0A    @Override%0A    public int getTotalEstimatedWorkSize()%0A    %7B%0A        return this.sourceList.size();%0A    %7D%0A%0A    /**%0A     * %7B@inheritDoc%7D%0A     */%0A    @Override%0A    public Collection%3CT%3E getNextWork()%0A    %7B%0A        final Collection%3CT%3E nextWork = new ArrayList%3C%3E(this.batchSize);%0A        while (this.sourceIterator.hasNext() && nextWork.size() %3C this.batchSize)%0A        %7B%0A            nextWork.add(this.sourceIterator.next());%0A        %7D%0A        return nextWork;%0A    %7D%0A%0A%7D%0A

Add collection-wrapping batch work provider