package de.avgl.dmp.converter.mf.stream;

import org.culturegraph.mf.framework.ObjectReceiver;

import com.google.common.collect.ImmutableList;

import de.avgl.dmp.persistence.model.internal.rdf.RDFModel;

/**
 * 
 * @author tgaengler
 *
 */
public class RDFModelReceiver implements ObjectReceiver<RDFModel> {

	private ImmutableList.Builder<RDFModel>	builder	= ImmutableList.builder();
	private ImmutableList<RDFModel>			collection;

	@Override
	public void process(final RDFModel rdfModel) {

		builder.add(rdfModel);
	}

	@Override
	public void resetStream() {

		builder = ImmutableList.builder();
	}

	@Override
	public void closeStream() {

		buildCollection();
	}

	public ImmutableList<RDFModel> getCollection() {

		if (collection == null) {

			buildCollection();
		}

		return collection;
	}

	private void buildCollection() {

		collection = builder.build();
	}
}

@@ -205,17 +205,16 @@
 %0A%0A/**%0A *
- 
 %0A * @aut
@@ -590,24 +590,45 @@
 .builder();%0A
+%09%09collection = null;%0A
 %09%7D%0A%0A%09@Overri

reset collection on Stream.reset()