/*
* Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* bstefanescu
*/
package org.eclipse.ecr.automation.core.collectors;
import java.util.ArrayList;
import org.eclipse.ecr.automation.OperationContext;
import org.eclipse.ecr.automation.OperationException;
import org.eclipse.ecr.automation.OutputCollector;
import org.eclipse.ecr.core.api.DocumentModel;
import org.eclipse.ecr.core.api.DocumentModelList;
/**
* This implementation collect {@link DocumentModel} objects and return them as a
* {@link DocumentModelList} object.
* <p>
* You may use this to automatically iterate over iterable inputs in operation
* methods that <b>return</b> a {@link DocumentModel} object
*
* @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
*
*/
public class DocumentModelListCollector extends ArrayList<DocumentModel> implements
DocumentModelList, OutputCollector<DocumentModelList, DocumentModelList> {
private static final long serialVersionUID = 5732663048354570870L;
@Override
public long totalSize() {
return size();
}
@Override
public void collect(OperationContext ctx, DocumentModelList obj)
throws OperationException {
addAll(obj);
}
@Override
public DocumentModelList getOutput() {
return this;
}
}